Swift 3-使用全屏显示时如何隐藏状态栏 [英] Swift 3 - how to hide Status Bar when using Over Full Screen
问题描述
我正在开发一个快速的应用程序,在我的模态中使用全屏显示"演示时,我找不到如何隐藏状态栏.
I'm developing a swift app and I can't find how to hide Status Bar when I use Over Full Screen presentation on my modal.
但是,我将这行代码放入了Modal View Controller中:
However, I put this line of code in my Modal View Controller :
override var prefersStatusBarHidden: Bool {
return true
}
如果我创建非模态的segue,或者创建模态但不具有全屏显示"功能的segue,则可以正常工作.
And it is working if I create a segue which is not a modal, or if I create a segue which is a modal but not with Over Full Screen presentation.
我在互联网上搜索了解决方法,发现存在相同问题但没有解决方案的人.
I searched on internet how to fix it, and I found people who had the same problem but there had no solution.
此外,当我使用全屏显示"选项时,无法更改状态栏的颜色.我不明白为什么?我认为这是相关的.
Also, I can't change the color of my Status Bar when I'm using Over Full Screen option. I don't understand why? I think it's related.
感谢您的帮助!
推荐答案
要在执行全屏模式时隐藏状态栏,您需要在viewDidLoad中进行设置:
To hide the status bar when doing an over full screen modal, you need to set this in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
modalPresentationCapturesStatusBarAppearance = true
}
然后执行隐藏状态栏的标准方法:
Then do the standard method to hide the status bar:
override var prefersStatusBarHidden: Bool {
return true
}
这篇关于Swift 3-使用全屏显示时如何隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!