Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 8 light status bar not working

Tags:

ios

swift

I've set the background color of the main UIView in my view controller to a bluish color.

I've also tried all combinations of the following:

  • Adding this to the app delegate:

    UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)

  • Setting View controller status based application to NO and YES

  • Setting 'Status Bar Style' to Light in the project overview.

I'm seeing black status bar text when I want to see white text.

I'd like to set the style at the application level, not the VC level.

My info.plist:

enter image description here

like image 868
Max Hudson Avatar asked May 01 '15 17:05

Max Hudson


People also ask

How do you override Preferredstatusbarstyle?

It is possible to override this on the UINavigationBar by setting overrideUserInterfaceStyle but this will result in the back list menu (from long press on back button) also having a dark mode style appearance.

Where is the status bar on iPhone?

The icons in the status bar at the top of the screen provide information about iPhone. On an iPhone with Face ID, there are additional status icons at the top of Control Center. Note: If you turn on a Focus, its icon appears in the status bar.

Can we change status bar color in iOS?

You can change the status bar colour just with a single line of code. Just updated the markdown for iOS 13 and below.


1 Answers

Status bar style is determined (by default) at the level of the view controller, not the application. Implement preferredStatusBarStyle in your view controller.

class ViewController : UIViewController {
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return .LightContent
    }
}

You can determine status bar style at the application level, but to do so, you must throw a switch in your Info.plist. See the docs:

To opt out of the view controller-based status bar appearance behavior, you must add the UIViewControllerBasedStatusBarAppearance key with a value of NO to your app’s Info.plist file, but doing so is not recommended [my italics, and I don't even know whether this is even supported any longer].

like image 60
matt Avatar answered Oct 22 '22 11:10

matt