React Navigation - Gradient color for Header

后端 未结 4 958
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 08:49

I am using React Navigation in React Native app and I want to change the backgroundColor for the header to be gradient and I found out there is a node module :

4条回答
  •  失恋的感觉
    2020-12-29 09:37

    You can use LinearGradient component from the expo. It is a useful component and you can't install another library like react-native-linear-gradient. https://docs.expo.io/versions/latest/sdk/linear-gradient/. By the way, you can change the back button. It is easy.

    You can implement it on inside screen with navigationOptions like that

    static navigationOptions = ({ navigation }: any) => {
      const onGoBack = () => navigation.goBack();
      return {
        header: (props: any) => ,
        headerStyle: { height: 68, backgroundColor: "transparent", color: colors.white },
        headerTitle: "Sign Up",
        headerTitleStyle: { color: colors.white, fontSize: 18 },
        headerLeft: (
          
            
          
        ),
      };
    };
    

提交回复
热议问题