【问题标题】:Change the background color of a screen with react native使用本机反应更改屏幕的背景颜色
【发布时间】:2018-04-14 18:22:39
【问题描述】:

我使用堆栈导航器导航到一个视图。新的屏幕有不同的背景颜色#E9E9EF,我不知道它来自哪里。我发现这个颜色是在 react-navigation/lib/views/CardStack/Card.js 中设置的。 我尝试更改视图背景颜色,但没有成功

return (
  <View style={{backgroundColor: '#F5FCFF'}}>
  </View>
)

我也尝试在 StackNavigator 中使用此代码更改卡片样式,但颜色没有改变

Other: {
    screen: AppOtherContainer,
    cardStyle: {backgroundColor: 'red'},
    navigationOptions: ({navigation}) => ({
      title: navigation.state.params.title
    })
  }

【问题讨论】:

    标签: reactjs react-native


    【解决方案1】:

    如果你想改变标题颜色,那么试试这个。

    static navigationOptions = {
         title: navigation.state.params.title,
         headerStyle: {backgroundColor:"red"}}
    

    如果要更改渲染屏幕的背景颜色,请设置

    &lt;View style={{backgroundColor: 'red', flex:1}}&gt; &lt;/View&gt;

    【讨论】:

    • 我要改变整个屏幕的颜色
    【解决方案2】:

    尝试将tintColor 添加到您的导航选项中

    static navigationOptions = {
        title: navigation.state.params.title,
        header: navigation => ({
          titleStyle: {
            color: '#FFFFFF'
          },
          tintColor: '#F5FCFF'
        })
    }
    

    【讨论】:

      猜你喜欢
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      • 2017-12-01
      • 1970-01-01
      • 2021-07-11
      • 2019-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多