react-nativestatusbar

BarStyle "dark-content" in StatusBar is not working in IOS (React Native)


I want that barStyle is always be "dark-content" in StatusBar in IOS. However, I see that text is still switching to white, when phone is in dark mode. Is there any solution to this problem? React Native version is "0.63.4".

import {
  Platform,
  StatusBar,
} from 'react-native';


 <StatusBar
          barStyle={Platform.OS === 'ios'? 'dark-content': 'default'}
        />

Solution

  • I found a solution. By removing barStyle from the component and adding this code inside useEffect() in App.js, it started working:

    useEffect(() => {
        StatusBar.setBarStyle(Platform.OS === 'ios'? 'dark-content': 'default')
    }, []);