Search code examples
swift3xcode8ios10statusbaravplayerviewcontroller

AVPlayerViewController causes status bar to become visible


In my app the status bar is hidden.

I am displaying video in a AVPlayerViewController, which has a visible status bar (I haven't found a way to remove it short of creating my own view controller, which I don't know how to do).

However, when the AVPlayerViewController is dismissed, the status bar is now visible in the app.

How to I prevent the player from causing the status bar becoming visible in the app?


Solution

  • After two days I finally find solution:

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        UIApplication.shared.setStatusBarHidden(true, with: .none)
    }
    

    Just skip warnings about setStatusBarHidden deprecation in iOS9.0 and bla.bla.bla. Because prefersStatusBarHidden just didn't worked!!!