React Native 中的状态栏颜色 [英] StatusBar color in React Native

查看:20
本文介绍了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 中的状态栏颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆