状态栏的颜色不会随着我的导航栏而改变

Color of status bar does not change as my navigationbar

我遇到了一个奇怪的问题。突然,我的状态栏的颜色没有改变为与我的 tabbarcontroller 中的导航栏相同的颜色。

我试过设置导航栏的颜色

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]

但它只是改变了导航栏的颜色,而不是状态栏。我错过了什么?

:

extension UIApplication {
    var statusBarView: UIView? {
        return value(forKey: "statusBar") as? UIView
    }
}

UIApplication.shared.statusBarView?.backgroundColor = .red

在情节提要中创建导航控制器,将其绑定到控制器并更改那里的颜色。如果它当然允许你的项目..