1

I am trying to get the following StatusBarStyle on my swift app :

enter image description here

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 :

enter image description here

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 :

enter image description here

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 :

white_text_on_gray_background_status_bar_style

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

black_text_on_light_blue_status_bar

Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
  • 1
    Check this question : http://stackoverflow.com/questions/32730211/how-we-can-set-the-light-content-style-of-status-bar-in-ios-9-for-whole-applicat and answer. You have to remove the plist entry. – Ashish Kakkad Oct 03 '15 at 05:14
  • Thanks for the suggestion. When I remove the plist entry and set self.nav?.navigationBar.barStyle = UIBarStyle.Black in AppDelegate, I get the following result : http://i.stack.imgur.com/tEcOm.png – Arunabh Das Oct 03 '15 at 05:25
  • Are you using storyboards? – Suhit Patil Oct 03 '15 at 06:33
  • I do have VCs in storyboards but I am not setting any properties on them in the IB. All the properties are getting set programmatically. – Arunabh Das Oct 03 '15 at 06:35
  • Setting the appearance property (that way it affects everything) is the easier way to go about this. – BonanzaDriver Oct 04 '15 at 03:12

2 Answers2

4

In appDelegate use:

  UINavigationBar.appearance().barTintColor = UIColor.redColor()
  UINavigationBar.appearance().translucent = false

Obviously you can use any UIColor you want...

0

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)
Akash Raghani
  • 557
  • 1
  • 9
  • 21