How to change the color of UIBarButtonItem on iOS 5

My most popular blog post is how to change the color of a UIBarButtonItem. It’s something that lots of people want to do, but it involved some pretty weird hacks to get it working.

Now that iOS 5 is out, I can talk about a better way to do it. Apple will now let you set the tintColor: property on the bar button item. That’s it. No more weird hacks with images or segmented controls.

There’s even a cool new appearance proxy that will let you change all controls from your app with a single line of code. (More about UIAppearance here)

So lets say you want every UIBarButtonItem in your application to be blue. That’s easy just call [UIBarButtonItem appearance] setTintColor:[UIColor blueColor]]

Remember, this is iOS 5 only. If you want your app to support iOS 4, you’ll have to do it the old way.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to How to change the color of UIBarButtonItem on iOS 5

  1. Pingback: How to change the color of a UIBarButtonItem | farp.blog

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>