正在努力理解如何更改导航标题栏的背景色.

backgroundColor似乎没有任何作用.知道怎么做吗?

我的代码如下:

static navigationOptions = () => ({
    title: 'My App',
    headerTintColor: Colors.DarkBlue,
    backgroundColor: 'red',
    headerLeft:
      <HeaderBarItem to='InfoScreen' title='App info' />,
    headerRight:
      <HeaderBarItem to='FeedbackScreen' title='Feedback' />
  });

推荐答案

这应该是有效的:

static navigationOptions = () => ({
    title: 'My App',
    headerTintColor: Colors.DarkBlue,
    headerStyle: {
      backgroundColor: 'red'
    },
    headerLeft:
      <HeaderBarItem to='InfoScreen' title='App info' />,
    headerRight:
      <HeaderBarItem to='FeedbackScreen' title='Feedback' />
  });

React-native相关问答推荐

'无法解析模块.安装react-native-pager-view后的实用程序/平台

如何防止 VS Code 从react-native-web自动导入?

如何在 React Navigation 5 中将父函数传递给子屏幕?

如何在 React Native 的嵌套 Touchable 中传播touch 事件?

子视图覆盖的容器borderRadius,这是一个bug吗?

react-native 中 android 和 iOS 的图像大小

运行react应用程序时出错

xcrun:错误:SDK "iphoneos" cannot be located

React native base headers for ios not found

如何从 React Native 应用程序打开 Google Play store ?

由于端口 8081 sunproxyadmin,无法打包 react native

在本react-native中具有异步和等待的箭头函数

在 Android React Native 应用程序中正确使用 Intl

react-native run-ios 运行失败: Application is unknown to FrontBoard?

加载远程图像失败后加载本map像

如何将样式传递给 React-Native 中的容器组件

如何更改键盘上的 return按钮?

使用 React Native 运行多个 iOS 模拟器?

react-native构建错误:package android.support.annotation does not exist

如何将图形 API 与 react-native-fbsdk 一起使用?