Gally Gally - 18 days ago 7
iOS Question

Change foregroundcolor of statusbar

I used this code in swift 2.3 to change the foreground color of status bar:

(application.value(forKey: "statusBar") as AnyObject).setValue(UIColor.red, forKey: "foregroundColor")


But in the update to swift 3.0 this part not work because the statusbar no have the foreground key.

Someone has been able to change the color of statusbar in swift 3.0 ?

Thank you.

Answer

i solve my problem with this lines in the AppDelegate:

let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView
statusBar.setValue(UIColor.red, forKey: "_foregroundColor")

Regards.