Bakari Lewis
Bakari Lewis

Reputation: 91

React-Native iOS Status Bar

I am using react-native to build a simple app. 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? I checked out this [doc][1], but its not recognizing 'route'. 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>      
    );
}

}`

Upvotes: 0

Views: 550

Answers (1)

Sagar Kachhadiya
Sagar Kachhadiya

Reputation: 1066

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

  }

});

Upvotes: 0

Related Questions