我想隐藏标题。使用 Expo Go 时它是隐藏的,但是当我将其发布并构建为 APK 并安装它时,标题变得可见

问题描述 投票:0回答:1

我遇到了 React Native 导航问题。使用Expo Go时,标题不可见,这正是我想要的。但是,当我使用 EAS Build 将应用程序构建为 APK 并将其安装在真实设备上时,会显示标题。

应用程序.js

const Stack = createStackNavigator();
const App = () => {
  const [isReady, setIsReady] = React.useState(false);

  return (

    <Provider store={store}>
      <NavigationContainer ref={navigationRef}>
        <Stack.Navigator
          screenOptions={{
            headerStyle: {
              display: 'none',
            },
            headerShown: false,
            header: null,
          }}
          initialRouteName={'SignIn'}
        >
          <Stack.Screen
            name="Register"
            component={Register}
            options={{
              headerShown: false,
              header: () => null, // Hide the header for MainLayout
            }}
          />
          <Stack.Screen
            name="Home"
            component={Home}
            options={{
              headerShown: false,
              header: () => null, // Hide the header for MainLayout
            }}
          />
          <Stack.Screen
            name="SignIn"
            component={SignIn}
            options={{
              headerShown: false,
              header: () => null, // Hide the header for MainLayout
            }}
          />
          <Stack.Screen
            name="ForgotPassword"
            component={ForgotPassword}
            options={{
              headerShown: false,
              header: () => null, // Hide the header for MainLayout
            }}
          />
          <Stack.Screen
            name="MainLayout"
            component={MainLayout}
            options={{
              headerShown: false,
              header: () => null, // Hide the header for MainLayout
            }}
          />
         
        </Stack.Navigator>
      </NavigationContainer>
      <FlashMessage
        style={{
          position: 'absolute',
          top: 0,
          zIndex: 9999
        }}
        position="top" />
    </Provider>

  );
}


export default App

我用的版本

"@react-navigation/drawer": "^5.12.5",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"expo": "^49.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-i18next": "^12.0.0",
"react-native": "0.72.5",

[![这个在展会上的 go 标题被隐藏][1]][1]

[![在 .apk 中构建它显示标题,我在真实设备上测试][2]][2]

世博会上的标题是隐藏的 [1]:https://i.stack.imgur.com/1PPam.jpg [2]:https://i.stack.imgur.com/ezXOr.jpg

react-native expo react-native-navigation eas
1个回答
0
投票

尝试将状态栏颜色设置为透明。我猜你遇到的这个问题只适用于 android,而不是 ios。

© www.soinside.com 2019 - 2024. All rights reserved.