如何在tabar(createMaterialToptabnavigator)中添加图标



hii我是新来的React Native,我正在使用Tabbar createMaterialTopTabnavigator,现在我想在标签中添加局部添加图标,我的代码是

 const TabScreen = createMaterialTopTabNavigator(
 {
   Home: { screen: Home },
   Settings: { screen: Settings }
 });

我有两个类名称为"主页"one_answers"设置也是我的标签代码

{
tabBarPosition: 'top',
swipeEnabled: true,
animationEnabled: true,
tabBarOptions: {
  activeTintColor: '#FFFFFF',
  inactiveTintColor: '#F8F8F8',
  style: {
    backgroundColor: '#633689',
  },
  labelStyle: {
    textAlign: 'center',
  },
  indicatorStyle: {
    borderBottomColor: '#87B56A',
    borderBottomWidth: 2,
  },
},}

您必须在选项卡屏幕中添加带有tabbaricon的导航选项,

 Home: {
      screen: Home,
      navigationOptions: {
        tabBarIcon: ({ tintColor }) => (
          //Your icon component for example => 
          <Icon name="home" size={30} color="#900" />
        )
      },
    }, 

并添加showicon:true在tabbaroptions中,

{
tabBarPosition: 'top',
swipeEnabled: true,
animationEnabled: true,
tabBarOptions: {
 showIcon: true,
  activeTintColor: '#FFFFFF',
  inactiveTintColor: '#F8F8F8',
  style: {
    backgroundColor: '#633689',
  },
  labelStyle: {
    textAlign: 'center',
  },
  indicatorStyle: {
    borderBottomColor: '#87B56A',
    borderBottomWidth: 2,
  },
},}

相关内容

  • 没有找到相关文章

最新更新