Umair Afzal Umair Afzal - 1 year ago 112
Swift Question

Hide status bar even when an alert is presented

I am hiding my status bar on a specific


override func prefersStatusBarHidden() -> Bool {
return true

It is working very nice until I present an alert on the screen. When alert is presented status bar appears again, Which I do not want. When alert is dismissed status bar is hidden again.

Answer Source

As UIAlertController is now a full-fledged UIViewController, you should be able to subclass it and add the same method to the new subclass. Then instanciate your subclass instead of a plain UIAlertController.

Untested, but that should do the trick.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download