【发布时间】:2016-09-27 15:27:30
【问题描述】:
我在 swift 2.3 中使用此代码更改状态栏的前景色:
(application.value(forKey: "statusBar") as AnyObject).setValue(UIColor.red, forKey: "foregroundColor")
但是在 swift 3.0 的更新中,这部分不起作用,因为状态栏没有前台键。
有人可以在swift 3.0中更改状态栏的颜色吗?
谢谢。
【问题讨论】:
我在 swift 2.3 中使用此代码更改状态栏的前景色:
(application.value(forKey: "statusBar") as AnyObject).setValue(UIColor.red, forKey: "foregroundColor")
但是在 swift 3.0 的更新中,这部分不起作用,因为状态栏没有前台键。
有人可以在swift 3.0中更改状态栏的颜色吗?
谢谢。
【问题讨论】:
我用 AppDelegate 中的这一行解决了我的问题:
let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
statusBar.setValue(UIColor.red, forKey: "_foregroundColor")
问候。
【讨论】: