How to disable the highlight control state of a UIButton?

kbanman picture kbanman · Feb 14, 2010 · Viewed 84.9k times · Source

I've got a UIButton that, when selected, shouldn't change state when being touched. The default behaviour is for it to be in UIControlStateHighlighted while being touched, and this is making me angry.

Suggestions?

Answer

Haydn picture Haydn · Feb 14, 2010

Your button must have its buttonType set to Custom.

In IB you can uncheck "Highlight adjusts image".

Programmatically you can use theButton.adjustsImageWhenHighlighted = NO;

Similar options are available for the "disabled" state as well.