0

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.

Fred Faust
  • 6,696
  • 4
  • 32
  • 55

1 Answers1

1

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().

Connor Neville
  • 7,291
  • 4
  • 28
  • 44