Search code examples
ioscocoa-touchuibuttonuikituicontrol

How to disable the highlight control state of a UIButton?


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?


Solution

  • 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.