Ivan Cantarino
Ivan Cantarino

Reputation: 3246

Cannot hide status bar if the ViewController is embeded in a NavigationController

As the title says, I cannot hide the status bar, with the regular prefersStatusBarHidden method if my UIViewController is within a UINavigationController.

If I present a UIViewController and the prefersStatusBarHidden returns true the status bar will be hidden, but if I embed the same UIViewController like the following:

let vc = VC()
let navc = UINavigationController(rootViewController: vc)
present(navc, animated: true, completion: nil)

The prefersStatusBarHidden will not be called.

Any hint on why this is happening??

Upvotes: 0

Views: 66

Answers (1)

matt
matt

Reputation: 535890

Presumably this is because you are testing on an iPhone X or similar no-bezel device. It is impossible to hide the status bar when there's a navigation bar on such a device.

Upvotes: 2

Related Questions