React Native, change React Navigation header styling

前端 未结 5 436
孤街浪徒
孤街浪徒 2021-02-01 19:54

I\'m implementing React Navigation in my React Native app, and I\'m wanting to change the background and foreground colors of the header. I have the following:

/         


        
5条回答
  •  醉梦人生
    2021-02-01 20:28

    In newer versions of React Navigation you have a flatter settings object, like below:

    static navigationOptions = {
      title: 'Chat',
      headerStyle: { backgroundColor: 'red' },
      headerTitleStyle: { color: 'green' },
    }
    

    Deprecated answer:

    Per the docs, here, you modify the navigationOptions object. Try something like:

    static navigationOptions = {
        title: 'Welcome',
        header: {
            style: {{ backgroundColor: 'red' }},
            titleStyle: {{ color: 'green' }},
        }
    }
    

    Please don't actually end up using those colors though!

提交回复
热议问题