hitv1q
Last Updated: September 13, 2018
·
12.22K
· mxcl

Mastering iOS 7 UIStatusBarStyle

iOS 7 introduces the UIViewControllerBasedStatusBarAppearance plist setting allowing us to change the statusBar’s text color when the main viewController changes.

Getting it to work can feel tricky however.

  1. Ensure you set UIViewControllerBasedStatusBarAppearance to boolean YES in your plist.
  2. Ensure you set still set the default statusBar style in your plist, this will show during the splash screen.
  3. Override preferredStatusBarStyle providing your viewController is not inside a UINavigationController.
  4. If your viewController is inside a navigationController then preferredStatusBarStyle seems to be ignored completely. Instead the navigationController’s navigationBar’s barStyle is used. A Dark barStyle makes the statusBar white, the default barStyle makes the statusBar text black.

This in fact makes some sense. The application queries the main viewController’s preferredStatusBar style, so if you have a navigationController the main viewController is the navigationController.

4 Responses
Add your response

10042

It's pretty logic that when your ViewController is inside the NavigationController, the setting is ignored. It's because the ViewController is added as a SubView for your NavigationController. :)

Extra tip:
I find it easier to define the main styles in the AppDelegate, so I have my default style like I want it. If I need to deviate from it, just change it in your ViewController.

over 1 year ago ·
10743

liked this post.. most of people dont know it i too had difficulty understanding it.....

over 1 year ago ·
11368

The best post around the net about status bar styles on iOS7! Props!!!

over 1 year ago ·
30687

OS 7 introduces the UIViewControllerBasedStatusBarAppearance plist setting allowing us to change the statusBar’s text color when the main viewController changes.
https://photomath.vip/
Getting it to work can feel tricky however.
https://textnow.vip/
Ensure you set UIViewControllerBasedStatusBarAppearance to boolean YES in your plist.
Ensure you set still set the default statusBar style in your plist, this will show during the splash screen.
Override preferredStatusBarStyle providing your viewController is not inside aUINavigationController.
If your viewController is inside a navigationController then preferredStatusBarStyle seems to be ignored completely. Instead the navigationController’s navigationBar’s barStyle is used. A Dark barStyle makes the statusBar white, the default barStyle makes the statusBar text black. https://bluestacks.vip/

3 months ago ·