简体   繁体   中英

Change Navigationbar Color swift

Here this code works and the color of the navigationbar changed to blue

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

BUT WHEN adding navigationController?.navigationBar.prefersLargeTitles = true

color does not change

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
}

与 navigationController?.navigationBar.prefersLargeTitles = true

Here you can use [navigationBar.backgroundColor] instead off [navigationBar. barTintColor]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM