3

I'm trying to change the style of statusBar, and I tried to use the following code:

override func viewWillAppear(animated: Bool) {
    //1
    UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent
    //2
    self.setStatusBarStyle(UIStatusBarStyle.LightContent)
    //3
    if self.respondsToSelector(#selector(setNeedsStatusBarAppearanceUpdate)){
        self.setNeedsStatusBarAppearanceUpdate()
    }

}

But this doesn't work, can anyone help me out.

MBH
  • 16,271
  • 19
  • 99
  • 149
L.yansun
  • 45
  • 5

2 Answers2

3

To your Info.plist file add this key-value pair:

 UIStatusBarStyle: UIStatusBarStyleLightContent

The default (black) value is UIStatusBarStyleDefault.

Jaimesh
  • 841
  • 4
  • 25
  • 41
  • Also define for IOS 7 in :http://stackoverflow.com/questions/18924345/how-to-change-status-bar-style-during-launch-on-ios-7 – Jaimesh May 14 '16 at 09:52
2

You have to set the "View Controller based status Bar apperance" to NO in you Info.plist.

Another option is:

override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return .LightContent
}

In your View Controller.

Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70