简体   繁体   English

如何在 IOS 中避免此状态栏问题?

[英]How i can avoid this Status bar issue in IOS?

In this below screenshot you can see when i present modally than the base viewController status bar is quickly hidden and when i dismiss this modal than is will quick show.在下面的屏幕截图中,您可以看到当我以模态呈现时,基本 viewController 状态栏被快速隐藏,当我关闭此模态时,它将快速显示。 so, How i can avoid this and fixed status bar when present modally.所以,当以模态方式出现时,我如何避免这个和固定的状态栏。

在此处输入图片说明

Thank you.谢谢你。

You can achieve your requirement by using below code.您可以使用以下代码实现您的要求。

Swift 3 & Swift 4斯威夫特 3 和斯威夫特 4

override var prefersStatusBarHidden: Bool {
  return true
}

you can update the state once the view controller is already being displayed, you will need to call:一旦视图控制器已经显示,您就可以更新状态,您需要调用:

setNeedsStatusBarAppearanceUpdate()

Please refer to the documentation .请参阅文档

override func viewDidLoad(){
    super.viewDidLoad()
    navigationController?.navigationBar.barStyle = .default
}

override var prefersStatusBarHidden: Bool {
    return true
}

I applied scroll view also in the same screen, by this code was able to resolve status bar issue.我也在同一屏幕中应用了滚动视图,通过此代码能够解决状态栏问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM