请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

设置tabBaiIcon不管用,使用react-native-vector-icons

正在回答 回答被采纳积分+3

1回答

CrazyCodeBoy 2018-11-28 09:52:12

检查下所使用的icon在https://oblador.github.io/react-native-vector-icons/ 中是否还存在,另外tabBarIcon的设置可参考一下代码:

export const MaterialTopTabNavigator = createMaterialTopTabNavigator({//在这里配置页面的路由
       Page1: {
           screen: Page1,
           navigationOptions: {
               tabBarLabel: 'Page10',
               tabBarIcon: ({tintColor, focused}) => (
                   <Ionicons
                       name={'ios-home'}
                       size={26}
                       style={{color: tintColor}}
                   />
               ),
           }
       },


0 回复 有任何疑惑可以回复我~
  • 提问者 barray #1
    我使用的是最新版本的react-native-vector-icons6.1.0与最新版的react-navigation3.0.0 然后按照上面的代码实现,无法实现图标的显示(╥╯^╰╥)
    回复 有任何疑惑可以回复我~ 2018-11-28 10:14:33
  • 提问者 barray #2
    使用react-navigation3.0.0文档中的代码无法实现
    export default createBottomTabNavigator(
      {
        Home: HomeScreen,
        Settings: SettingsScreen,
      },
      {
        defaultNavigationOptions: ({ navigation }) => ({
          tabBarIcon: ({ focused, horizontal, tintColor }) => {
            const { routeName } = navigation.state;
            let iconName;
            if (routeName === 'Home') {
              iconName = `ios-information-circle${focused ? '' : '-outline'}`;
            } else if (routeName === 'Settings') {
              iconName = `ios-options${focused ? '' : '-outline'}`;
            }
            return <Ionicons name={iconName} size={horizontal ? 20 : 25} color={tintColor} />;
          },
        }),
        tabBarOptions: {
          activeTintColor: 'tomato',
          inactiveTintColor: 'gray',
        },
      }
    );
    回复 有任何疑惑可以回复我~ 2018-11-28 10:23:10
  • 提问者 barray #3
    老师,我知道原因了,使用defaultNavigationOptions可以,但是使用tNavigationOptions就不显示了ε(┬┬﹏┬┬)3
    回复 有任何疑惑可以回复我~ 2018-11-28 10:29:11
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信