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
In Swift 3 is like that:
for those still working with Swift 3 in Xcode 8:
( slightly different to Marlon Ruiz's answer above, not an override function, but within viewDidLoad )
To dynamically update UIStatusBarStyle on view controllers use this method
this will also remove deprecated warning
'setStatusBarStyle:' is deprecated: first deprecated in iOS 9.0 - Use -[UIViewController preferredStatusBarStyle]
for calling
Let's Get Started
Objective - C
define UtilityFunction
over-ride this method in your BaseViewController
set UIStatusBarStyle value for the AnyViewController using a UtilityFunction like below:
Swift 4.0
define UtilityFunction
over-ride this method in your BaseViewController
set UIStatusBarStyle value for the AnyViewController using a UtilityFunction like below:
In info.plist, set:
View controller-based status bar appearance
boolean toNO
In app delegate's
didFinishLaunchingWithOptions
, use function parameterapplication
(and not the[UIApplication sharedApplication]
or simillary theUIApplication.sharedApplication()
in swift) to set this like so:In swift 3.
In your view controller:
If you wish when the app run your launch screen also has the status bar in lightContent then:
This worked fine for me in Xcode 7.
In AppDelegate: