How to set UIButton's Highlight Tint color programmatically?

ios, ios5, objective-c

Solution

You can set it as

[button setTintColor:[UIColor grayColor]];

This is equivalent to hightlight tint option in IB and is applied only for highlighted state.

Update: In order to implement this for all the buttons in app, use this:

[[UIButton appearance] setTintColor:[UIColor orangeColor]]; 

It will set for all the `UIButton` which you are going to use in your app.

Check this for more details on UIAppearance protocol.

Problem

There is a `Highlight Tint` option in Interface Builder for `UIButton`. Is it possible to change it programmatically for all `UIButton` in iOS 5....using some kind of appearance protocol thing or some other workaround?

Original source