iPhone Set Tint Color of Back Bar Button Item

user717452 picture user717452 · Jul 20, 2012 · Viewed 52.1k times · Source

I am trying to set the tint color of the back button within a navigation controller, but nothing is working. I have tried

[self.navigationController.backBarButtonItem setTintColor:myColor];
//myColor was previously set

But it stays the default tint

Answer

Qiming picture Qiming · Jul 20, 2012

I believe barButtonItem is read-only. (I'm not too sure about this, someone correct me if I'm wrong)

To give a tint colour to these buttons, this is what I would do:

In your App Delegate, add these lines of code:

UIBarButtonItem *barButtonAppearance = [UIBarButtonItem appearance];
[barButtonAppearance setTintColor:[UIColor redColor]]; // Change to your colour

The first line sets an appearance proxy, so I believe this works too, if you like less code:

[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];

I hope this works for you! (This changes all instances of UIBarButtonItem)