ios - 如何隐藏状态栏+在另一个 View Controller (swift)中使用白光内容?

标签 ios swift

我想在第一个 Controller 中隐藏状态栏,但我也希望它出现在 lightContent 中的第二个 Controller 中。

我用过:

UIApplication.shared.statusBarStyle = .lightContent

对于轻内容和

override var prefersStatusBarHidden: Bool {
    return true
}

隐藏状态栏。

我的问题是在 .plist 文件中将基于 View Controller 的状态栏外观设置为是/否将禁用一个或另一个。

最佳答案

如果你想在 ViewController 中隐藏状态栏,你可以使用这段代码轻松实现

在viewWillAppear中

UIApplication.shared.isStatusBarHidden = true

在 View 中会消失

UIApplication.shared.isStatusBarHidden = false

在 info.plist 中

<key>UIViewControllerBasedStatusBarAppearance</key><false/>

在 didFinishLaunchingWithOptions 中

UIApplication.shared.statusBarStyle = .lightContent

关于ios - 如何隐藏状态栏+在另一个 View Controller (swift)中使用白光内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52403292/

相关文章:

ios - 在IOS应用中使用Apple Touch ID

objective-c - 如何将此点表示法转换为嵌套的Objective-C中括号?

ios - 在 iOS 中请求相机权限对话框启动(主要权限)

swift - swift 文件的输出编译持续时间

swift - 没有 'dequeueReusableCellWithIdentifier' 候选产生预期的上下文结果类型 'DynamicTableViewCell?'

iphone - UIActivityController 是如何呈现的?

ios - UILabel 在输入一些文本后显示点

ios - NSPredicate 按年月日过滤

iphone - 如何在 swift 中而不是在 uiimageview 上设置图像边框?

ios - 在 Xcode 中均匀分布按钮