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.

4

2 Answers 2

3

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

 UIStatusBarStyle: UIStatusBarStyleLightContent

The default (black) value is UIStatusBarStyleDefault.

1
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.

3
  • Not copied, but the same solution. Commented May 14, 2016 at 9:50
  • @Dejan Skledar: Kindly provide a link to the answer instead of copying and pasting it.
    – iYoung
    Commented May 14, 2016 at 9:53
  • Since when is my experience copying another answer? Commented May 14, 2016 at 9:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.