Reputation: 14392
I am trying to get the following StatusBarStyle on my swift app :
My AppDelegate uses a UINavigationController as follows
self.nav = UINavigationController(rootViewController: controller!)
So I tried to set the UIBarStyle to Black as follows :
self.nav?.navigationBar.barStyle = UIBarStyle.Black
However, this results in the following :
BTW, on my Info.plist, I have the following set
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
And those settings result in the desired statusbar style on the LaunchScreen but not on the other screens.
I even tried adding the following method to all the VCs inside the UINavigationController
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.Default
}
But that results in the following status bar style :
What is the best way to have the desired status bar style in the case where you have a UINavigationController on iOS 9?
Additionally, if I remove the plist entry and set
self.nav?.navigationBar.barStyle = UIBarStyle.Black
in AppDelegate, I get the following result :
Additionally, I removed all the places where backgroundColor was being set except the following in AppDelegate (colorOne is the deepBlue color I want on the status bar)
self.window?.backgroundColor = colorOne
And when I did this, I get a light blue color on the status bar, which is the closest color to the deep blue color I need on the status bar as seen here
Upvotes: 1
Views: 728
Reputation: 557
i hope this may help you..
if you need a specific color, how you do it with RGB is the best option:
UINavigationBar.appearance().barTintColor = UIColor(red: 5.0, green: 8.0, blue: 9.0, alpha:0.5)
if its not working then try this: var navigationBarAppearace = UINavigationBar.appearance()
navigationBarAppearace.tintColor = UIColor.whiteColor()
navigationBarAppearace.barTintColor = UIColor(red:15/255.0, green: 167/255.0, blue: 216/255.0, alpha: 1.0)
Upvotes: 0
Reputation: 181
In appDelegate use:
UINavigationBar.appearance().barTintColor = UIColor.redColor()
UINavigationBar.appearance().translucent = false
Obviously you can use any UIColor you want...
Upvotes: 4