如何将徽章图标添加到BottomTabNavigator选项卡图标?

时间:2019-08-05 09:36:47

标签: react-native react-navigation

我正在使用React Navigation,想知道如何在底部标签中添加徽章?

像“提醒”选项卡一样,如果我有3条提醒,我希望在“提醒”标签的图标的右上角有一个3的徽章

const TabStack = createBottomTabNavigator(
  {
    Home : { screen: HomeStack },
    Reminders: { screen: ReminderStack},
  },

  {
    defaultNavigationOptions: ({ navigation }) => ({
      tabBarIcon: ({ focused, horizontal, tintColor }) => {
        const { routeName } = navigation.state;
        let IconComponent = Ionicons;
        let iconName;
        if (routeName === 'Home') {
          iconName = `ios-home`;
        } else if (routeName === 'Reminders') {
          iconName = `ios-alarm`;
        }

        return <IconComponent name={iconName} size={25} color={tintColor} />;
      },
    }),
    tabBarOptions: {
      activeTintColor: '#0892d0',
      inactiveTintColor: 'gray',
    },
  }
);

0 个答案:

没有答案
相关问题