4 MINDS

4MINDS Gestão de Conhecimento

IOS Change status bar text color and background color



In Info.plist add:

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackTranslucent</string>

<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

So you can hide navigation bar and save text color.

In AppDelegate add:

func setStatusBarBackgroundColor() {    
  guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }    
  statusBar.backgroundColor = UIColor.init(red: 65/255.0, green: 65/255.0, blue: 66/255.0, alpha: 100.0)
}

And call this function in didFinishLaunchingWithOptions. This make status bar background color dark.


In NavigationBar Storyboard change style to Black and uncheck Translucent box, like this:



This make status bar text color white.


Result: