【发布时间】:2017-02-09 16:12:30
【问题描述】:
在 XCode 7.3.x 中,我更改了 StatusBar 的背景颜色:
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else {
return
}
statusBar.backgroundColor = color
}
但这似乎不再适用于 Swift 3.0。
我试过了:
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = (UIApplication.shared.value(forKey: "statusBarWindow") as AnyObject).value(forKey: "statusBar") as? UIView else {
return
}
statusBar.backgroundColor = color
}
但它给了我:
this class is not key value coding-compliant for the key statusBar.
任何想法如何用 XCode8/Swift 3.0 改变它?
【问题讨论】:
标签: ios swift swift3 statusbar uistatusbar