How do I hide the shadow under react-navigation headers?

后端 未结 14 971
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-03 21:30

How do I hide the shadow under react-navigation headers?
They look like this.

相关标签:
14条回答
  • 2021-02-03 21:47

    As of 2019 this answer doesn't work in version 3.

    The new way of doing it is:

    
    const AppNavigation = StackNavigator(
      {
        'The First Screen!': { screen: FirstScreen },
      },
      {
        defaultNavigationOptions: {
          headerStyle: {
            elevation: 0,
            shadowOpacity: 0,
          },
        },
      },
    );
    
    
    0 讨论(0)
  • 2021-02-03 21:57

    The following works for me as the original Stylesheet uses "borderBottomWidth" on iOS:

    const navigator = StackNavigator(screens, {
      navigationOptions: {
        headerStyle: {
          elevation: 0,
          shadowOpacity: 0,
          borderBottomWidth: 0,
        }
      }
    });
    
    0 讨论(0)
  • 2021-02-03 21:58

    In v5 you can do the following

    <Stack.Navigator>
          <Stack.Screen
            name="Example"
            component={ExampleComponent}
            options={{
              headerStyle: {
                elevation: 0,
                shadowOpacity: 0
              },
            }}
          />
    </Stack.Navigator>

    0 讨论(0)
  • 2021-02-03 22:00

    For React Native Navigation 5

    <Stack.Screen
          name={"Profile"}
          component={Profile}
          options={{
            headerTitle: "Profile",
            headerHideShadow: true,
          }}
        />
    

    Or

    <Stack.Navigator
        screenOptions={{
          headerHideShadow: true,
        }}
      >
    
    0 讨论(0)
  • 2021-02-03 22:05

    The shadow is achieved via elevation, use:

     headerStyle: {
         backgroundColor: 'white',
         shadowColor: 'transparent',
         elevation: 0,
     },
    
    0 讨论(0)
  • 2021-02-03 22:06

    I don't know how much this answer will value, but sharing my code to let you know that this worked for me for react-navigation version: 3.9.1

    const AppNavigation = StackNavigator(
    {
      FirstScreen,
    },
    {
     defaultNavigationOptions: {
      headerStyle: {
        elevation: 0, //for android
        shadowOpacity: 0, //for ios
        borderBottomWidth: 0, //for ios
      },
    },
    })
    
    0 讨论(0)
提交回复
热议问题