我正在使用react-native来构建一个简单的应用程序。尝试更改状态栏中的背景颜色和内容颜色时遇到错误。我目前正在iPhone 8上进行测试。有人知道如何对状态栏进行这些更改吗?我签出了此[doc] [1],但无法识别“路线”。请帮忙。谢谢:)`
render() {
return (
<View>
<StatusBar
backgroundColor="red"
barStyle="light-content"
/>
<Button
title="go to Home"
color ="#841584"
onPress={() => this.props.navigation.push('Home')} />
</View>
);
}
}`
答案 0 :(得分:0)
请尝试以下代码
import React, { Component } from 'react';
import { StyleSheet, View, StatusBar, Text, Platform } from 'react-native';
export default class Myproject extends Component {
render() {
return (
<View style={styles.MainContainer}>
<StatusBar
barStyle="dark-content"
hidden={false}
backgroundColor="#fff"
translucent={true}
networkActivityIndicatorVisible={true}
/>
<Text style={{ textAlign: 'center', fontSize: 25 }}> React Native Status Bar Example Tutorial </Text>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer: {
backgroundColor: 'red',
justifyContent: 'center',
flex: 1,
marginTop: (Platform.OS == 'ios') ? 30 : 0
}
});