Ändern der Farbe der Statusleiste in Swift 3

In XCode 7.3.x krank verändert die Hintergrundfarbe für meine StatusBar mit:

func setStatusBarBackgroundColor(color: UIColor) {
guard  let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else {
    return
}
statusBar.backgroundColor = color
}

Aber es scheint, dass dies nicht mehr funktioniert mit Swift 3.0.

Krank versucht mit:

func setStatusBarBackgroundColor(color: UIColor) {
guard  let statusBar = (UIApplication.shared.value(forKey: "statusBarWindow") as AnyObject).value(forKey: "statusBar") as? UIView else {
    return
}
statusBar.backgroundColor = color
}

Aber es gibt mir:

this class is not key value coding-compliant for the key statusBar.

Irgendwelche Ideen, wie ändern es mit XCode8/Swift 3.0?

InformationsquelleAutor der Frage derdida | 2016-10-01

Schreibe einen Kommentar