斯威夫特3 |无法隐藏ViewController上的状态栏 [英] Swift 3 | Unable to hide status bar on a ViewController

查看:60
本文介绍了斯威夫特3 |无法隐藏ViewController上的状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在纵向模式下显示状态栏,当我旋转屏幕时,状态栏会按预期隐藏,但是如果按下/显示新的View Controller,状态栏会再次出现.

I want to show the status bar on portrait mode only, when I rotate the screen the status bar hides as intended but if I push / show a new View Controller the status bar appears again.

我尝试了以下操作但未成功:

I've tried the following without success:

  • info.plist 文件
  • 中将基于视图控制器的状态栏外观设置为 NO
  • 自身 NavigationController
  • 上使用 setNeedsStatusBarAppearanceUpdate()
  • prefersStatusBarHidden:Bool 设置为 true
  • 还尝试了 UIApplication.shared.setStatusBarHidden(true,使用:UIStatusBarAnimation.none)
  • 还扩展了NavigationController.在此处看到
  • Setting View controller-based status bar appearance to NO in the info.plist file
  • Using setNeedsStatusBarAppearanceUpdate() on self and on NavigationController
  • Setting prefersStatusBarHidden: Bool to true
  • Also tried UIApplication.shared.setStatusBarHidden(true, with: UIStatusBarAnimation.none)
  • Also extending NavigationController. seen here

任何帮助将不胜感激.谢谢.

Any help will be appreciated. Thanks.

推荐答案

尝试遵循代码

override var prefersStatusBarHidden: Bool {

    if UIDevice.current.orientation.isPortrait{
        return false
    }
    return true
}

这篇关于斯威夫特3 |无法隐藏ViewController上的状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆