Search code examples
iosswiftios8uistatusbar

Swift UIApplication.setStatusBarStyle Doesn't work


Here's my implementation in a subclass of UIViewController:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
}

I tried putting it in AppDelegate initialisation code (using the passed in UIApplication instance), however the status bar is still black..

Is this a bug with iOS 8 or am I doing it wrong?

Note: I may be breaking someone's law's here by discussing ios 8.. Its a general problem that, when compiled doesn't work for ios 7 either.

Update: Still doesn't work, even with value in Info.plist and code in - didFinishLaunchingWithOptions Nope still doesn't work


Solution

  • You really should implement preferredStatusBarStyle on your view controller(s):

    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .LightContent
    }