StatusBar color in React Native(React Native 中的状态栏颜色)
问题描述
如何更改 StatusBar
的背景颜色react-native
中的 组件,无需编辑 Android 特定文件?
How can I change background color of StatusBar
component from react-native
, without editing Android specific files?
文档 说,我可以使用 backgroundColor
属性.但它失败了.barStyle
属性,setBarStyle
&&setBackgroundColor
静态方法也不能正常工作.
Docs says, that I can use backgroundColor
property. But it fails. barStyle
property, setBarStyle
&& setBackgroundColor
static methods don`t work properly too.
只有 hidden
属性有效.
我正在使用 create-react-native-app
,使用 Expo 构建.
推荐答案
在Expo App中,你需要在你的项目根目录下编辑app.json
,如下所示:
In Expo App, you need to edit app.json
in your project root directory like this:
{
"expo": {
"sdkVersion": "16.0.0",
"androidStatusBar": {
"barStyle": "dark-content",
"backgroundColor": "#0A48A5"
}
}
}
参见世博会文档:https://docs.expo.io/versions/v16.0.0/guides/configuration.html
这篇关于React Native 中的状态栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!