Xcode 8.2: Swift3- 如何隐藏状态栏?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41255816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:40:03  来源:igfitidea点击:

Xcode 8.2: Swift3- how to hide status bar?

iosswiftxcode

提问by john afordis

all trying to hide status bar with Xcode 8.2 with swift 3. but I can't hide it.

所有人都试图用 Xcode 8.2 和 swift 3 隐藏状态栏。但我无法隐藏它。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

and also for,

也为了,

enter image description here

在此处输入图片说明

回答by Museer Ahamad Ansari

You can Approach this in two ways

您可以通过两种方式解决此问题

Option 1.Try this in didFinishLaunchingWithOptionsMethod

选项 1 .didFinishLaunchingWithOptions方法中试试这个

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    UIApplication.shared.isStatusBarHidden = true

    return true
}

Option 2. overrideprefersStatusBarHiddenfunction in your UIViewController

选项 2prefersStatusBarHidden在您的覆盖功能UIViewController

override var prefersStatusBarHidden : Bool {
    return true
}

Note:you call override func prefersStatusBarHiddenit should be override var prefersStatusBarHidden

注意:你调用override func prefersStatusBarHidden它应该是override var prefersStatusBarHidden

回答by KAR

In swift 3 use this,

在 swift 3 中使用这个,

override var prefersStatusBarHidden: Bool {  
    return true  
}

Reference link

参考链接

回答by Suhit Patil

override prefersStatusBarHiddenin your view controller

prefersStatusBarHidden在您的视图控制器中覆盖

override var prefersStatusBarHidden : Bool {
        return true
    }

true if the status bar should be hidden or false if it should be shown.

如果状态栏应该隐藏,则为 true,如果应显示,则为 false。

Refer apple doc link

参考苹果文档链接