Color of status bar does not change as my navigationbar

拈花ヽ惹草 提交于 2019-12-11 15:28:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!