如何将图标添加到此选项卡导航器?

时间:2019-12-05 23:17:31

标签: react-native react-native-navigation

const OneNav = createStackNavigator({
  Home: {screen: pages.Home},
  Social: {screen: pages.Social},
  House: {screen: pages.House},
},{
  initialRouteName: 'Home',
});

const TwoNav = createStackNavigator({
  Home: {screen: Two}
},{
  initialRouteName: 'Home',
});

const TabNav = createBottomTabNavigator({
  Home: {screen: OneNav},
  Interact: {screen: TwoNav},
},{
  initialRouteName: 'Check',
  defaultNavigationOptions: {
    headerTitle: () => (
      <View>
        <Logo />
      </View>)
  }
});

现在我有一个带有2个标签的标签导航器,分别是Home和Interact。如何在导航器中为每个选项卡添加图标?请在上面的代码中向我展示我将如何做,而不是从React Native网站上获得一些示例代码。谢谢!

1 个答案:

答案 0 :(得分:0)

尝试以下

const TabNav = createBottomTabNavigator({
  Home: {
    screen: OneNav,
    navigationOptions: () => ({
        tabBarIcon: ({ tintColor }) => <Icon name="home" type="font-awesome" color={tintColor} />,
    }),
  },
  Interact: {
    screen: TwoNav,
    navigationOptions: () => ({
        tabBarIcon: ({ tintColor }) => <Icon name="home" type="font-awesome" color={tintColor} />,
    }),
  },
},{
  initialRouteName: 'Check',
  defaultNavigationOptions: {
    headerTitle: () => (
      <View>
        <Logo />
      </View>)
  }
});