ramsserio ramsserio - 5 months ago 10
iOS Question

NavigationBar appearance() (tint color ..)

How can I set a tint color to a specific navigation controller ?

Because by using :

UINavigationBar.appearance().barTintColor = UIColor(red: 0.1, green: 0.22, blue: 0.212, alpha: 1)


The color will be set to all navigation controllers , isn't it ?

I've tried this code but it is not working ! Why ?

let nav = UINavigationController(rootViewController: feedvc)
nav.navigationBar.appearance().barTintColor = UIColor(red: 0.1, green: 0.22, blue: 0.212, alpha: 1)

Answer

You can set the tint of a specific controller by accessing barTintColor directly:

nav.navigationBar.barTintColor = UIColor(red: 0.1, green: 0.22, blue: 0.212, alpha: 1)