正如标题所说,如果我的 UIViewController
在 UINavigationController
中,我无法使用常规的 prefersStatusBarHidden
方法隐藏状态栏。
如果我呈现一个 UIViewController
并且 prefersStatusBarHidden
返回 true
状态栏将被隐藏,但是如果我嵌入相同的 UIViewController
如下所示:
let vc = VC()
let navc = UINavigationController(rootViewController: vc)
present(navc, animated: true, completion: nil)
prefersStatusBarHidden
不会被调用。
关于为什么会发生这种情况的任何提示?
最佳答案
这大概是因为您正在 iPhone X 或类似的无边框设备上进行测试。在这种设备上有导航栏的情况下,隐藏状态栏是不可能的。
关于ios - 无法隐藏 ViewController 的状态栏嵌入在 NavigationController 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55769054/