Joseph K Joseph K - 1 year ago 529
Swift Question

prefersStatusBarHidden, preferredStatusBarStyle properties in Swift 3

Starting Swift 3 / iOS 10, methods such as preferredStatusBarStyle and prefersStatusBarHidden became:

@available(iOS 7.0, *)
open var preferredStatusBarStyle: UIStatusBarStyle { get }

@available(iOS 7.0, *)
open var prefersStatusBarHidden: Bool { get }

As such existing code that used to override the methods no longer builds. Given these properties are readonly, how can you assign them a value / override them?

Answer Source

You need to learn that in Swift (since the first public beta pre-1.0), you can override properties. Read-only properties can be overridden like this:

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