reactjs - 在 TabNavigator 中隐藏标签 - ReactNavigation

标签 reactjs react-native react-navigation tabnavigator

如何隐藏 TabNavigator 中的标签并仅显示图标?如果我执行以下操作:

const Tabs = TabNavigator({
  Home: {
    screen:MainHome,
    navigationOptions: ({ navigation }) => ({
        title: "Home",  //Tried to hide this for next tab Search.
        tabBarIcon: ({ tintColor, focused }) => <View><MaterialIcons name="home"/></View>
      })
  },
  Search: {
    screen:TestComp1,
    navigationOptions: ({ navigation }) => ({
      //If no title it shows the name as Search.
      tabBarIcon: ({ tintColor, focused }) => <View><MaterialIcons name="accessibility"/></View>
    })

  }
}, { 

   tabBarPosition: 'bottom',

   tabBarOptions: {
    showIcon: true,
    activeTintColor: '#e91e63',  //Not working for icons.
    inactiveBackgroundColor: 'green', // Not working at all.
    style: {backgroundColor: '#3498DB', height: 60, padding:0, margin:0}
  }
});

如果我从 navigationOptions 中删除 title,它会显示选项卡的名称(HomeSearch) 。我只想显示图标并更改事件图标的颜色。 activeTintColor 不适用于图标。

最佳答案

TabNavigator 有您可以设置的 showLabel 属性。更多信息请引用docs for v1docs for v2 .

showIcon - whether to show icon for tab, default is false

showLabel - whether to show label for tab, default is true

关于reactjs - 在 TabNavigator 中隐藏标签 - ReactNavigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46770273/

相关文章:

android-studio - React-Native Run-Android 和 React-Native Start

react-native - React Native - 像 Material Bottom Navigator 一样向 Material Top Navigator 显示标签栏徽章

reactjs - 使用 Redux Thunk 和 Apollo Graphql 进行 react - 如何访问 client.query?

javascript - 无效字符错误: Failed to execute 'createElement' on 'Document' : The tag name provided ('/static/media/tab1.fab25bc3.png' ) is not a valid name

html - UseParallax ref hook 不适用于 NextJs 中的组件

javascript - 如何避免 redux 中的重复代码(鸭子方法)?

ios - react native : "setBackgroundColor is only available on android" warning on iOS

javascript - React-navigation 在调试时工作正常但在 Release模式下不工作

react-native - 如何从抽屉屏幕更新标题栏

javascript - 为什么 React 函数组件的 "this"未定义