Wei Jay Wei Jay - 1 year ago 507
iOS Question

How to set Status Bar Style in Swift 3

I'm using Xcode 8.0 beta 4.

In previous version, UIViewController have method to set the status bar style

public func preferredStatusBarStyle() -> UIStatusBarStyle

However, I found it changed to a "Get ONLY varaiable" in Swift 3.

public var preferredStatusBarStyle: UIStatusBarStyle { get }

How can provide the style to use in my UIViewController?

Answer Source

You could try to override the value returned, rather than setting it. The method is declared as { get }, so just provide a getter:

 override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download