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

查看:586
本文介绍了React Native中的StatusBar颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 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屋!

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