如何在iOS 9中隐藏单个视图控制器的状态栏? [英] How to hide status bar of a single view controller in iOS 9?

查看:357
本文介绍了如何在iOS 9中隐藏单个视图控制器的状态栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我以模态方式呈现的ViewController中,我这样做了:

In a ViewController, which I presented modally, I did this:

override func prefersStatusBarHidden() -> Bool {
    return true
}

这曾经有效,但没有更长的作品。隐藏此视图控制器的状态栏的最佳方法是什么?

This used to work, but it no longer works. What's the best way to hide the status bar only for this view controller?

推荐答案

对于 Swift 3 & Swift 4 它已更改为覆盖此变量:

For Swift 3 & Swift 4 it has changed to overriding a variable like this:

override var prefersStatusBarHidden: Bool {
  return true
}

如果你想更新状态一旦视图控制器已经显示,您需要调用:

If you want to "Update" the state once the view controller is already being displayed, you will need to call:

setNeedsStatusBarAppearanceUpdate()

请参阅文档

这篇关于如何在iOS 9中隐藏单个视图控制器的状态栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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