我正在使用 react-navigation v2 并反应原生矢量图标。
我正在尝试在反应原生选项卡导航器中添加一个图标。
如果该图标不在选项卡导航器中,则会显示该图标。该图标未显示在选项卡导航器中,我找不到如何在选项卡导航器中添加图标的可靠示例。
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { createMaterialTopTabNavigator } from 'react-navigation'
import Home from '../HomePage.js'
import Profile s from '../ProfilePage.js'
import Icon from 'react-native-vector-icons/FontAwesome';
export const Tabs = createMaterialTopTabNavigator(
{
HomePage: {
screen: Home,
navigationOptions: {
tabBarLabel:"Home Page",
tabBarIcon: ({ tintColor }) => (
<Icon name="home" size={30} color="#900" />
)
},
},
ProfilePage: {
screen: Profile,
navigationOptions: {
tabBarLabel:"Profile Page",
tabBarIcon: ({ tintColor }) => (
<Icon name="users" size={30} color="#900" />
)
}
},
},
{
order: ['HomePage', 'ProfilePage'],
tabBarOptions: {
activeTintColor: '#D4AF37',
inactiveTintColor: 'gray',
style: {
backgroundColor: 'white',
}
},
},
)
原文由 jrocc 发布,翻译遵循 CC BY-SA 4.0 许可协议
想通了必须添加
在此之后,图标显示。