0
votes

I have a UIViewcontroller sub-class with the following properties:

    override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
        return .slide
    }
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    override var prefersStatusBarHidden: Bool {
        return false
    }

And would like to change preferStatusBarHidden to true based on method calls, after view controller init. I am unable to change it to true (it's get only).

I think I'm missing something silly here...

Edit: This is not a duplicate from other hide status bar questions because it involves a property override and computation to determine the property after the view controller has already been presented.

1
Possible duplicate of Hiding status bar iOS 7brimstone
@brimstone this is not a duplicate, the properties in the question didn't even exist in iOS 7.Fred Faust

1 Answers

1
votes

Add your logic for when the status bar should be hidden inside the getter for prefersStatusBarHidden (where you currently just have return false). Then, when you need to trigger an update, call setNeedsStatusBarAppearanceUpdate().