问题
I bumped into an odd problem. Suddenly the color of my status bar does not change color to the same as my navigationbar in my tabbarcontroller.
I've tried setting the color of the navigationbar
self.navigationController!.navigationBar.barTintColor = UIColor(red: 57, green: 79, blue: 116)
self.navigationController?.navigationBar.tintColor = UIColor.white
self.navigationController?.navigationBar.isTranslucent = false
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
But it just change the color of the navigationbar, not the statusbar. What am I missing?
回答1:
Answer found here:
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
UIApplication.shared.statusBarView?.backgroundColor = .red
回答2:
create navigation controller in storyboard, tie it to controller and change the color of there. If it allows your project of course..
来源:https://stackoverflow.com/questions/49077574/color-of-status-bar-does-not-change-as-my-navigationbar