这是我的代码:
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}
/>
正如你在docs中看到的那样,正确的方法是backgroundColor =“white”。也许还有另一个问题。你在哪台设备上测试?尝试没有半透明(我知道它应该工作,但也许你的Android版本有一个错误)。尝试使用rgb颜色(#ff0000)。让我知道你的结果。