react-native - 为什么我不能更改状态栏的颜色?
问题描述
这是我的代码:
import React, { Component } from 'react';
import {StatusBar,Platform,Text,StyleSheet,View} from 'react-native';
export default class TabsScrollableExample extends Component {
render() {
return (
<View style={styles.container}>
<StatusBar
barStyle = "light-content"
hidden = {false}
style={styles.color} // I've also tried this way backgroundColor="white"
translucent = {true}
networkActivityIndicatorVisible = {true}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container :{
backgroundColor:"white",
},
color:{
backgroundColor:"white"
}
});
所有其他属性都可以正常工作,但背景颜色不会改变。
我不知道问题出在哪里。
解决方案
像这样使用。
<StatusBar
barStyle = "light-content"
hidden = {false}
backgroundColor="white"
translucent = {true}
networkActivityIndicatorVisible = {true}
/>
推荐阅读
- html - 即使禁用了选定的选项,如何制作所需的选择语句
- ios - 如何使 UISearchbar 变成矩形并与导航栏合并?
- c++ - 为什么要删除非成员函数?
- python - Python程序将输出作为嵌套字典计数
- java - 尝试调用虚方法:空对象引用
- python - Python json.loads() 如何处理字符串中的非转义引号
- android - 当用户单击列表视图的项目时,是否可以显示 admob 插页式广告?
- eclipse - 如何在eclipse中打印原始编译时错误?
- scala - 如何在 Scala 的过滤器中使用 if-else 条件?
- php - php Mysqli 查询不返回任何值或错误