0

I have task where I need to change the statusbar from white and make the content dark. Now I search how the statusbar implement to the component. Yes it works properly. Later on I experience bugs where If I re render the entire application I mean when I re open the application again. the status bar that I change it turns to the original color which is blue. so to make more details I will show you the code that I implement and the screenshot of my application that I created.

Here is some research that I read: Reference

I don't think there is any conflict between react-navigation and the StatusBar, but I think you should use the component rather than the imperative API. There's a high chance this is due to a re-render of your app and it just switch back to the default, with a component declare, you ensure it won't happen.

Goal: To make the statusbar won't change to blue if I re open the application again.

Here is what I implement on my application:

  1. React Navigation 5 (For Navigation)
  2. Native Base

Statusbar:

 <StatusBar hidden={false} animated  barStyle="dark-content" backgroundColor="#FFFF" />

Bug Status Bar:

Bug Status Bar

Goal Status Bar:

Target Status Bar

DevGe
  • 1,381
  • 4
  • 35
  • 66

1 Answers1

0

Code Works might only for the android device as we have to manage the safeAreaView in iOS device

Check out the below code example to show the custom status bar color.

<View style={{ flex: 1 }} >
  <StatusBar animated backgroundColor="pink" barStyle="dark-content" />
  <View style={{ flex: 1, backgroundColor: "green" }} >

  </View>
</View>

Might you will be able to see the status bar color pink and dark content into it and whole screen with green color.

Jignesh Mayani
  • 6,937
  • 1
  • 20
  • 36