IOS 8 status light not working

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

I have also tried all combinations of the following:

  • Adding this to the app delegate:

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

  • Setting View status based on controller status for NO and YES

  • Setting the "Status Bar" for lighting in the project overview.

I see black line text when I want to see white text.

I would like to set the styling at the application level, not the VC level.

My info.plist:

enter image description here

+3


source to share


3 answers


The status bar style is defined (by default) at the view controller level, not the application level. Inject preferredStatusBarStyle

into your controller.

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

      



You can define the style of the status bar at the application level, but for that you have to throw a switch in your Info.plist. See docs :

To opt out of the controller-based control panel appearance behavior, you must add a UIViewControllerBasedStatusBarAppearance

NO key to your application's Info.plist file, but this is not recommended [my italics and I don't even know if this is even more supported].

+7


source


for IOS 9+

In your plist file change, add / modify a table with these 2 lines.

1) View controller-based status bar appearance

toNO



2) Status bar style

beforeUIStatusBarStyleLightContent

enter image description here

+7


source


you can use this code

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

      

can solve this problem.

+1


source







All Articles