【问题标题】:Change Navigationbar Color swift快速更改导航栏颜色
【发布时间】:2020-08-03 12:29:32
【问题描述】:

此代码有效,导航栏的颜色变为蓝色

override func viewDidLoad() {
    super.viewDidLoad()
    navigationItem.title = "Countries"
    navigationController?.navigationBar.barTintColor = UIColor.blue
    tabBarController?.tabBar.tintColor = UIColor.white
    view.backgroundColor = .white
}

但是当添加navigationController?.navigationBar.prefersLargeTitles = true

颜色不变

override func viewDidLoad() {
    super.viewDidLoad()
    navigationItem.title = "Countries"
    navigationController?.navigationBar.prefersLargeTitles = true
    navigationController?.navigationBar.barTintColor = UIColor.blu
    tabBarController?.tabBar.tintColor = UIColor.white
    view.backgroundColor = .white
}

【问题讨论】:

标签: ios swift uinavigationbar


【解决方案1】:

在这里你可以使用 [navigationBar.backgroundColor] 代替 [navigationBar.backgroundColor]。 barTintColor]

    navigationItem.title = "Countries"
    
    navigationController?.navigationBar.prefersLargeTitles = true
    
    navigationController?.navigationBar.backgroundColor = UIColor.blue
    
    tabBarController?.tabBar.tintColor = UIColor.white
    
    view.backgroundColor = .white

【讨论】:

    猜你喜欢
    • 2020-10-27
    • 1970-01-01
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    相关资源
    最近更新 更多