如何在react native中将图像添加为图标?

时间:2018-10-06 14:20:26

标签: javascript react-native

因此,我对原生反应非常陌生。我最近一直在从事一个项目,并且制作了一个图标,希望将其放置在我的本机应用程序的顶部(以及标题)。这是一个png图像。以下是我的主屏幕代码。

import React, { Component } from "react";
import {
    View,
    Text,
    StyleSheet,
    Platform
} from "react-native";

import HomeTab from './AppTabNavigator/HomeTab'
import SearchTab from './AppTabNavigator/SearchTab'
import AddMediaTab from './AppTabNavigator/AddMediaTab'
import LikesTab from './AppTabNavigator/LikesTab'
import ProfileTab from './AppTabNavigator/ProfileTab'

import { createBottomTabNavigator } from 'react-navigation'
import { Icon } from 'native-base'

class MainScreen extends Component {
    static navigationOptions = {

        title: "AaROGYA SAMAJ",    //This is the heading
        headerTintColor: '#000000',
        headerAlignement: "center",
        headerStyle: {
            backgroundColor: '#8dbef5',
          },
          headerTitleStyle: {
            fontSize: 18,
            fontWeight: "bold",
            alignItems: "center",
            justifyContent: "center",
          },
    }
    render() {
        return (
            <AppTabNavigator />
        );
    }
}

export default MainScreen;

const AppTabNavigator = createBottomTabNavigator({

    Feeds: {
        screen: HomeTab
    },

    TagDumpingSite: {
        screen: AddMediaTab
    },

    Community: {
        screen: LikesTab
    },

    Profile: {
        screen: ProfileTab
    },

}, {
        animationEnabled: true,
        swipeEnabled: true,
        tabBarPosition: "bottom",
        tabBarOptions: {
            style: {
                ...Platform.select({
                    android: {
                        backgroundColor: '#8dbef5'
                    }
                })
            },
            activeTintColor: '#000',
            inactiveTintColor: '#1113a4',
            showLabel: true,
            showIcon: true
        }
    })

const styles = StyleSheet.create({
    container: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
        backgroundColor: '#7078f7',

    },
});

如您所见,“ AaROGYA SAMAJ”是我的应用程序的标题名称。刚好沿着这个标题,我要添加文件夹中的图像(徽标或图标)。有人可以帮忙吗?  ps:我想将其放在导航标签的中心。

1 个答案:

答案 0 :(得分:0)

没有更多信息就无济于事,我想这可能会有帮助? https://facebook.github.io/react-native/docs/image