0

I try to put my Status Bar in Light Content.
The problem is that I have set View controller-based status bar appearance to YES .

enter image description here

In my ViewController I put :

override open var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

I also try to put this in my AppDelegate :

application.statusBarStyle = .lightContent

After thats I still have a Dark (black) Status Bar.

Krunal
  • 77,632
  • 48
  • 245
  • 261
Max0u
  • 691
  • 1
  • 9
  • 21

4 Answers4

2

ios 10 and swift 3

Change in info.plist the row View controller-based status bar appearance and set it to NO

Change in appDelegate.swift in didFinishLaunchingWithOptions

UIApplication.shared.statusBarStyle = .lightContent

In perticular viewcontroller use

override var preferredStatusBarStyle: UIStatusBarStyle {
   return .lightContent
}
Nikhlesh Bagdiya
  • 4,316
  • 1
  • 19
  • 29
  • I can't set it to NO because when I load a Youtube Video with the WebView the status bar disappear – Max0u Jul 20 '17 at 11:50
0

In your ViewController's viewDidLoad method try calling

    self.setNeedsStatusBarAppearanceUpdate()
Aravind A R
  • 2,674
  • 1
  • 15
  • 25
0
didFinishLaunching Method in AppDelegate Class Single line code.

application.statusBarStyle = .lightContent
Inder_iOS
  • 1,636
  • 1
  • 12
  • 20
0

Here is Apple Guidelines/Instruction about status bar change. Only Dark & light (while & black) are allowed in status bar.

Here is - How to change status bar style:

If you want to set status bar style, application level then set UIViewControllerBasedStatusBarAppearance to NO in your `.plist' file.

if you wan to set status bar style, at view controller level then follow these steps:

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file, if you need to set status bar style at UIViewController level only.
  2. In the viewDidLoad add function - setNeedsStatusBarAppearanceUpdate

  3. override preferredStatusBarStyle in your view controller.

-

override func viewDidLoad() {
    super.viewDidLoad()
    self.setNeedsStatusBarAppearanceUpdate()
}

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

Set value of .plist according to status bar style setup level. enter image description here

Krunal
  • 77,632
  • 48
  • 245
  • 261