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 中的状态栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:React Native 中的状态栏颜色
基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
