我想在第一个 Controller 中隐藏状态栏,但我也希望它出现在 lightContent 中的第二个 Controller 中。
我用过:
UIApplication.shared.statusBarStyle = .lightContent
对于轻内容和
override var prefersStatusBarHidden: Bool {
return true
}
隐藏状态栏。
我的问题是在 .plist 文件中将基于 View Controller 的状态栏外观设置为是/否将禁用一个或另一个。
最佳答案
如果你想在 ViewController
中隐藏状态栏,你可以使用这段代码轻松实现
在viewWillAppear中
UIApplication.shared.isStatusBarHidden = true
在 View 中会消失
UIApplication.shared.isStatusBarHidden = false
在 info.plist 中
<key>UIViewControllerBasedStatusBarAppearance</key><false/>
在 didFinishLaunchingWithOptions 中
UIApplication.shared.statusBarStyle = .lightContent
关于ios - 如何隐藏状态栏+在另一个 View Controller (swift)中使用白光内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52403292/