从底部选项卡导航隐藏/删除图标或图标视图

Vik*_*sal 4 react-native react-navigation react-navigation-bottom-tab

我想从底部选项卡导航器中删除图标空间/视图。我尝试通过删除 tabBarIcon 来删除图标,但它不起作用。这是我尝试过的代码和我收到的结果。看起来不太好,标签不在中心。他们看起来好像已经进入了可见屏幕下方。使用的代码:

const TabNavigator = createMaterialBottomTabNavigator(
{
    Home: {
        screen: screen1,
        navigationOptions: {
            // tiitle: "hello"
            // tabBarIcon: () => {
            //     <View></View>
            // },
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline', }}>Screen1</Text>,
        }
    },
    People: {
        screen: screen2,
        navigationOptions: {
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline' }}>Screen2</Text>,
            activeColor: '#E8947F',
            inactiveColor: '#C4C9CB',
        }
    },
    Connects: {
        screen: screen3,
        navigationOptions: {
            tabBarLabel: <Text style={{ fontSize: 15, textDecorationLine: 'underline' }}>Screen3</Text>,
            activeColor: '#E8947F',
            inactiveColor: '#C4C9CB',

            // barStyle: { backgroundColor: '#2c6d6a' },
        }
    },
},
{
    initialRouteName: 'Home',
    activeColor: '#E8947F',
    inactiveColor: '#C4C9CB',
    barStyle: { backgroundColor: '#00000000' },
});
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述

我是 React-Native 的新手。请帮我。

Viv*_*k S 11

您只需添加screenOptions={{tabBarIconStyle: { display: "none" }}}如下例所示。

<Tab.Navigator
  screenOptions={{
    tabBarLabelPosition: "beside-icon",
    tabBarLabelStyle: {
      fontWeight: "700",
      fontSize: 15
    },
    tabBarIconStyle: { display: "none" },
  }}
>
  <Tab.Screen
    component={DemoComponent}
    name="Demo"
    options={{ tabBarLabel: "My Demo" }}
  />
</Tab.Navigator>
Run Code Online (Sandbox Code Playgroud)


小智 9

只需要在 Tab.Screen 中添加此选项即可将其隐藏在 TabNavigator 中,如下所示。

<Tab.Screen name="Home" component={HomeStack} options={{
    tabBarButton: () => null,
    tabBarVisible: false,
  }} />
Run Code Online (Sandbox Code Playgroud)