状态栏的颜色不会更改为我的导航栏

问题描述 投票:0回答:2

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

enter image description here

我试过设置导航栏的颜色

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]

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

ios swift uitabbarcontroller navigationbar
2个回答
-1
投票

Answer found here

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

UIApplication.shared.statusBarView?.backgroundColor = .red

0
投票

在故事板中创建导航控制器,将其绑定到控制器并更改其中的颜色。如果它允许你的项目当然..

© www.soinside.com 2019 - 2024. All rights reserved.