本文介绍了状态栏的颜色未更改,因为我的导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我碰到一个奇怪的问题.突然,状态栏的颜色不会更改为与我的tabbarcontroller中的导航栏相同的颜色.
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?
推荐答案
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
UIApplication.shared.statusBarView?.backgroundColor = .red
这篇关于状态栏的颜色未更改,因为我的导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!