Reputation: 44352
Is there a way to change only the left side back button color in an app with a navigation controller?
There are plenty of examples changing colors in the navbar but those all affect the navbar title as well. I don't want to change the title. Just the back button (text + chevron) color.
Upvotes: 11
Views: 9981
Reputation: 418
Use Below To Change Back Button Color:
navigationController?.navigationBar.tintColor = UIColor.red
To Change Title Color of The Navigation Bar Use:
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
Upvotes: 25
Reputation: 2245
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.navigationBar.tintColor = UIColor.white
self.navigationController?.navigationBar.barTintColor = UIColor.black
self.navigationController?.navigationBar.titleTextAttributes = UIColor.blue
}
Upvotes: 0
Reputation: 427
UINavigationBar.appearance().backgroundColor = UIColor.greenColor()
UIBarButtonItem.appearance().tintColor = UIColor.magentaColor()
Since iOS 7.0 UITextAttributeTextColor was replaced by NSForegroundColorAttributeName
UINavigationBar.appearance().titleTextAttributes = [UITextAttributeTextColor: UIColor.blueColor()]
UITabBar.appearance().backgroundColor = UIColor.yellowColor();
Upvotes: 1