Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native change status bar text color in iOS

I'm developing an app using React Native, I've been asked to set the text color of the status bar in white.

I used the StatusBar component with the property barStyle="light-content" and it works pretty well on Android but not on iOS, the text color is still black.

I did some research about it but I couldn't find anything helpful. I even tried to select the Light Status bar style on XCode like the following picture shows but it still doesn't work

like image 259
Fabrizio Avatar asked Oct 05 '18 07:10

Fabrizio


People also ask

How set background color of status bar in iOS react-native?

Add import { StatusBar } from 'react-native'; to the top of your app. js and then add StatusBar. setBarStyle('light-content', true); as the first line in your render() to change the status bar text/icons to white. The other color options are 'default' and 'dark-content' .

How do I change the color of my status bar text?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.

How do I add color to my status bar in react-native?

setBackgroundColor() Set the background color for the status bar. Background color. Animate the style change.

How do I change the color of my status bar in react-native Expo?

You can't change the color of the iOS status bar. You can use the React Native StatusBar module to either hide it, or set the text color to light (white) or dark (black).


1 Answers

I solved the problem! I use this code in Index page and set the text color to white:

<StatusBar  barStyle="light-content" translucent={true} />
like image 80
hook zou Avatar answered Sep 18 '22 12:09

hook zou