2

In one view I am hiding the navigation bar using:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    self.navigationController?.navigationBarHidden = true
    }

This makes the status bar background color appear as white. But how do I change the background color of the status bar?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2722667
  • 8,195
  • 14
  • 52
  • 100
  • I think you should change your view's or root window's background color as I suspect that your status bar is transparent. – Ozgur Vatansever Jul 20 '15 at 01:34
  • @ozgur My status bar is red, with white text, or it used to be. But the root view has red background color and white text – user2722667 Jul 20 '15 at 01:37
  • @ozgur If I set the background color of the viewcontrollers root view to eg red. It looks fine. But since I have an scroll view and then scroll to the bottom it will show a red background color at the bottom as well. When you scroll to the end and keep dragging, that bounce effect will show a red color – user2722667 Jul 20 '15 at 01:42
  • The status bar doesn't have a *background* color any more... does it? – nhgrif Jul 20 '15 at 01:50
  • status bar can have only two styles, default (which is black) and light content. - http://rshankar.com/how-to-customize-status-bar-in-ios/ – rshankar Jul 20 '15 at 02:58
  • @rshankar the status bar can take the navigation bars tint color. Is there no way to keep that tint color once the navigation bar is hidden? – user2722667 Jul 20 '15 at 19:15
  • @nhgrif It can take the navigation bars tint color. I am hiding the navigation bar for one view which results in the status bar appearing as white – user2722667 Jul 20 '15 at 19:19
  • http://stackoverflow.com/a/39802582/2019221 – Callam Oct 01 '16 at 15:11

2 Answers2

0

You can have a light color and dark color for your status bar

 UIApplication.sharedApplication().setStatusBarStyle(.LightContent, animated: true)

(or)

  UIApplication.sharedApplication().setStatusBarStyle(.Default, animated: true)
  • 1
    This only makes the text / background white or black. I want to set the background color of the status bar to red – user2722667 Jul 20 '15 at 18:54
0

You can change the status bar styles by setting a key "Status Bar Style" in the info.plist.

The following three different styles are present for status bars:- Status bar style - String

  1. Gray style (default)
  2. Transparent black style (alpha of 0.5)
  3. Opaque black style

enter image description here

You can also change the setting from all view controllers to view controller based status bar, by changing the following key in the info.plist:-

View controller-based status bar appearance - Boolean

  1. Yes
  2. No

enter image description here

Arpit Dhamane
  • 503
  • 7
  • 19