Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIApplication.sharedApplication().setStatusBarStyle() deprecated in iOS 9

I have been using

UIApplication.sharedApplication().setStatusBarStyle()

In my appDelegate and it has worked fine, but since iOS 9, this method is deprecated and I can't find an alternative.

I want to change the statusbar style to .LightContent for my whole application, but the only suggestion xCode gives me is to handle this in every VC separately with;

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

Has anyone an idea how to do this for the whole application?

Thanks in advance

like image 692
Rick Avatar asked Sep 10 '15 11:09

Rick


2 Answers

I think I have found a solution. I ended up setting the

View controller-based status bar appearance boolean to NO

In my info.plist file.

Info.Plist

Then I went to my target's General settings -> Deployment info and changed the dropdown option Status Bar Style to Light instead of Default

Change Status Bar Style to Light

This changed the statusbar style to Light for my whole application, just what I wanted.

I Hope this helps!

like image 171
Rick Avatar answered Oct 13 '22 10:10

Rick


In swift 3.

In your view controller:

override var preferredStatusBarStyle: UIStatusBarStyle {
    return UIStatusBarStyle.lightContent
}

If you wish when the app run your launch screen also has the status bar in lightContent then:

enter image description here

like image 10
Marlon Ruiz Avatar answered Oct 13 '22 08:10

Marlon Ruiz