Status bar stays black even when set to light

Hi,

first pardon me if I made a post on the wrong forum part, this is my first post on this forum so I am still trying to figure my way around.


Now, here is a problem I am experiencing:

I have app compatible with iPad and iPhone in Swift, supporting iOS 7 and 8, using XCode 6.4. Now I made app structured as master-detail control and set in split controller status bar to be light (white). In Storyboard, all controllers display white status bar (master, detail, naigation controllers...) but nor in simulator nor in iPhone / iPad is white but black!


I tried in each controller and its naviagator controller to set light status bar. Tried in Master view controller to set it. Tried to add in plist option that allows me setting up per view controller (note that I do not want to control status bar color per controller but to set global for the app). Also tried to set override function for status bar style and even reload function in viewDidLoad func. And nothing worked. 😟


I am really stuck here; I thought just set in split control light status bar and everywhere else it inherits it (and that's how it indeed looks in stoyboard). So what am I missing? Can anyone help me out or give me some hints or directions in further investigation?


Many thanks in advance!

Answered by Dejan in 52611022

Ok found it.

  • In plist set "View controller-based status bar appearance" to NO
  • In appDelegate.swift in func application before return true add following line:
splitViewController.navigationController?.navigationBar.tintColor = UIColor.whiteColor()

Without seeing any code it's hard to tell, but here are a few random points about the status bar...

- as of iOS 7, the light / dark refers to the *text*, not the background, of the status bar. The bar itself is transparent and shows whatever you have drawn behind it.

- if you are changing it in code you should make sure you call setNeedsStatusBarAppearanceUpdate in your VC.

- if your view is not set to extend under the top bar, so you're not drawing anything under it, then the background will always be black, since the status bar is always transparent.

Right, here is a basic demo code: https://goo.gl/U3Ynbc

Note the following:

  • In project configuration, General tab, Status Bar style is set to Light
  • In Main.storyboard, SplitViewController is set to light, and then both navigation controllers and master and detail controllers also have status bar light (they all use "Inferred" which means I haven't set per view; reminder: I want light status bar in whole app so I do not care for status bar style per view).


I tried multiple stuff, in combination and alone:

  • setNeedsStatusBarAppeareanceUpdate() in viewDidLoad
  • Override function for status bar style
  • Setting light status bar style in storyboard and / or in code for each VC
  • In plist setting up parameter View controller-based status bar appearance (tried both NO and YES)
  • ....

As you can see in this demo project, I see in all VCs light status bar, but not on simulators and devices iPhone / iPad. If you can help me out in solving this mystery by fixing this demo app or by hints and directions, I'll be very grateful.


Additional note: project supports iOS 7 and up.


Thanks again!

Accepted Answer

Ok found it.

  • In plist set "View controller-based status bar appearance" to NO
  • In appDelegate.swift in func application before return true add following line:
splitViewController.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
Status bar stays black even when set to light
 
 
Q