swift 隐藏状态栏_Swift 3-使用全屏显示时如何隐藏状态栏

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.

However, I put this line of code in my Modal View Controller :

override var prefersStatusBarHidden: Bool {

return true

}

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.

Thanks for your help!

解决方案

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

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值