Reputation: 2094
I am developing an app for iOS8, using Swift 1.2.
However, I am having an issue with the colour of the status bar (the one with the time, battery indicator etc).
In my Info.plist
file, I have UIViewControllerBasedStatusBarAppearance
set to YES
as well as Status bar style
set to UIStatusBarStyleLightContent
and then in all my view controllers in the Storyboard, I have the status bar set to "Light Content".
This works for all of my NavigationViewControllers
and views embedded within NavigationViewControllers
, however I have one normal TableViewController
which is not embedded in a NavigationController
, and when I push this view modally, the status bar changes to BLACK!???
Even when I look at the view in the Storyboard editor it shows as a white status bar (note the faint white battery indicator at the right of the below screenshot):
But when I build and run on my iPhone, the status bar shows as black...
Why is this? How can I fix this? I don't know what could be incorrect.
Upvotes: 1
Views: 5994
Reputation: 2094
UPDATE:
I found the solution to this was very easy, from another StackOverflow article (Swift UIApplication.setStatusBarStyle Doesn't work).
For anyone else wanting to set the status bar colour programmatically, I just inserted the following code into my ViewController for the view in question:
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .LightContent
}
Upvotes: 3
Reputation: 748
For Swift 3
in your AppDelegate.swift
file in function didFinishLaunchingWithOptions
UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent
Upvotes: 1
Reputation: 4171
add this Line in your Appdelegate.swift
file :
UIApplication.sharedApplication().statusBarStyle = .LightContent
Upvotes: 0
Reputation: 23053
These are setups for UIStatusBar
style:
Go to AppDelegate.swift
in that add below code line in didFinishLaunchingWithOptions
method:
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
Add below keys into .plist
file.
UINavigationController
or UIViewController
. And set status bar style as Light Content
Upvotes: 2
Reputation: 4819
Please make sure to add View controller-based status bar appearance
(UIViewControllerBasedStatusBarAppearance) with value NO
to your Info.plist
Upvotes: 3