简体   繁体   English

React-Native iOS状态栏

[英]React-Native iOS Status Bar

I am using react-native to build a simple app. 我正在使用react-native来构建一个简单的应用程序。 I am running into an error when trying to change the background color and content color in the Status bar. 尝试更改状态栏中的背景颜色和内容颜色时遇到错误。 I currently am testing on my iPhone 8. Does any know how to make these changes to status bar? 我目前正在iPhone 8上进行测试。有人知道如何对状态栏进行这些更改吗? I checked out this [doc][1], but its not recognizing 'route'. 我签出了此[doc] [1],但无法识别“路线”。 please help. 请帮忙。 thanks :) ` 谢谢:)`

render() {

    return (

        <View>
            <StatusBar
            backgroundColor="red"
            barStyle="light-content"
             />
            <Button
                    title="go to Home"
                    color ="#841584"
            onPress={() => this.props.navigation.push('Home')} />

        </View>      
    );
}

}` }`

please try this code 请尝试此代码

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

  }

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM