Swift UIApplication.setStatusBarStyle不起作用 [英] Swift UIApplication.setStatusBarStyle Doesn't work

查看:695
本文介绍了Swift UIApplication.setStatusBarStyle不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在 UIViewController 的子类中的实现:

Here's my implementation in a subclass of UIViewController:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
}

我尝试将其放入AppDelegate初始化代码中(使用传入的UIApplication实例),但状态栏仍为黑色..

I tried putting it in AppDelegate initialisation code (using the passed in UIApplication instance), however the status bar is still black..

这是iOS 8的错误还是我做错了?

Is this a bug with iOS 8 or am I doing it wrong?

注意:我可能违反某人的法律这里通过讨论ios 8 ..它是一个普遍的问题,当编译时对ios 7也不起作用。

Note: I may be breaking someone's law's here by discussing ios 8.. Its a general problem that, when compiled doesn't work for ios 7 either.

更新:仍然不起作用,即使有价值在Info.plist和中的代码 - didFinishLaunchingWithOptions

Update: Still doesn't work, even with value in Info.plist and code in - didFinishLaunchingWithOptions

推荐答案

你真的应该在您的视图控制器上实现 preferredStatusBarStyle

You really should implement preferredStatusBarStyle on your view controller(s):

override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return .LightContent
}

这篇关于Swift UIApplication.setStatusBarStyle不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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