使用React Native在选项卡栏中显示图标

问题描述 投票:0回答:1

我是新来的本地人,正在尝试在我的标签菜单中显示图标。

我已经尝试使用FontAwesome,FontAwesome5,react-native-vector-icons和Ionicons。这些似乎都没有显示任何图标,我也不知道为什么。

tab bar

这是我的代码。

const TabNavigator = createBottomTabNavigator({
  Home: { 
    screen: HomeScreen,
    defaultnavigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <Icon name="home" color="#ccc"size={25} />
        )
    },
  },
   
  Events: { 
    screen: EventScreen,
     defaultnavigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <Icon name="home" color="#ccc"size={25} />
        )

  },
  About: { 
    screen: AboutScreen,
     defaultnavigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <Icon name="home" color="#ccc"size={25} />
        )
  }
},
 { tabBarOptions: { 
    showIcon: true,
    activeTintColor: '#D4AF37',
      inactiveTintColor: 'gray',
      style: {
       backgroundColor: 'white', 
},
  labelStyle: {
    fontSize: 20,
  }
}
 }
);
javascript reactjs react-native icons
1个回答
0
投票

尝试这种方式

const MainNavigator = createBottomTabNavigator(
  {
    Home: {
      screen: HomeNavigation,
      navigationOptions: ({navigation}) => ({
        title:  'home',
        tabBarIcon: <Icon name="home" color="#ccc"size={25} />,
      }),

    },
 {
    initialRouteName: 'Home',
    lazy: false,
    tabBarOptions: {
        activeTintColor: '#d63921',
        labelPosition: 'below-icon'
      },
  },
);

毫无疑问。

© www.soinside.com 2019 - 2024. All rights reserved.