删除 React 导航 v6 中的标题

Iba*_*man 6 react-native react-native-navigation react-navigation

使用自定义样式删除 React 导航 6 中的标头,这是堆栈导航的代码

 <NavigationContainer>
  <Stack.Navigator
    initialRouteName='OtpScreen'
    // screenOptions={{
    //   headerShown: false,
    // }}
    screenOptions={{ headerMode: 'none' }}
  >
    <Stack.Screen
      options={{ headerShown: false }}
      name='Tabs'
      component={MyTabs}
    />

  </Stack.Navigator>
</NavigationContainer>
Run Code Online (Sandbox Code Playgroud)

标签导航

   <Tab.Navigator
  useHeaderHeight={false}
  screenOptions={
    ({
      headerShown: false,
    },
    ({ route }) => ({
      tabBarIcon: ({ focused, color, size }) => {
        let iconName;

        if (route.name === 'Home') {
          iconName = focused
            ? 'ios-information-circle'
            : 'ios-information-circle-outline';
        } else if (route.name === 'Settings') {
          iconName = focused ? 'ios-list' : 'ios-list';
        }

        // You can return any component that you like here!
        return <Ionicons name={iconName} size={size} color={color} />;
      },
      tabBarActiveTintColor: 'tomato',
      tabBarInactiveTintColor: 'gray',
    }))
  }
>
Run Code Online (Sandbox Code Playgroud)

我使用了所有可能的解决方案仍然没有得到答案我想将它与自定义样式一起使用,如图所示

Iba*_*man 7

像这样添加

 <Stack.Navigator
    initialRouteName='OtpScreen'
    screenOptions={{
      headerShown: false,
    }}
    screenOptions={{ headerMode: 'none' }}
  ></Stack.Navigator>
Run Code Online (Sandbox Code Playgroud)

headerShown: false,这会起作用

  • `screenOptions={{ headerShown: false }}` 对我有用,但 `headerMode` 没有 (2认同)