AVPlayerViewController causes status bar to become visible

711 views Asked by At

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?

2

There are 2 answers

0
Jasur Rajabov On BEST ANSWER

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!!!

0
Adeesh Jain On

Don't use deprecated method. Its bad practice. Proper solution for hiding status bar for AVPlayerViewController :

extension AVPlayerViewController {

    open override var prefersStatusBarHidden: Bool {
        return true
    }
}