React Native中的StatusBar颜色 [英] StatusBar color in 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 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"
}
}
}
请参阅Expo文档: https://docs.expo.io/versions/v16.0.0/guides /configuration.html
See Expo documentation: https://docs.expo.io/versions/v16.0.0/guides/configuration.html
这篇关于React Native中的StatusBar颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!