Search code examples
iphonecocoa-touchuibuttonuievent

Disable UIButton blue color when Touch event occurs


When my button is pressed, I don't want it's appearance to change. It changes blue while I touch it. I tried going into IB and unchecking "Highlighted adjusts image" but that didn't seem to change anything. I also have "Shows touch on highlight" unchecked. How do I disable this? Thanks for any input.


Solution

  • This solution isn't neat, but it does what you want.

    Basically, you create an action method called deselect. And, depending on how little you want it to highlight, you hook several actions up to it. The easiest is just to hook up touch down, touch up inside and outside. However, if you want to insure that even if the user drags it doesn't get highlighted, you also hook it up to touch drag inside and outside.

    The method should look like this:

    - (IBAction)deselect:(id)sender {
        [sender setHighlighted:NO];
    }
    

    Hope that helps!