反应原生 iOS 状态栏



我正在使用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>      
);
}

}'

请尝试此代码

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
}
});

最新更新