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?

Joe
  • 2,386
  • 1
  • 22
  • 33
  • *"As such existing code that used to override the methods no longer builds."* – Are you sure? What error do you get? – `open` means that you *can* override the property in your subclass (http://stackoverflow.com/questions/38947101/what-is-the-open-keyword-in-swift) – Martin R Sep 05 '16 at 20:02

3 Answers3

6

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
}
OOPer
  • 47,149
  • 6
  • 107
  • 142
0

Now you'll need to Override the property:

override var prefersStatusBarHidden: Bool{
    get{
        return true
    }
}
0

You can override preferredStatusBarStyle in Your Viewcontroller

like this

 override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
Ucdemir
  • 2,852
  • 2
  • 26
  • 44