PDA

View Full Version : Override Highlighted for UIButton?




ArtOfWarfare
Dec 9, 2009, 10:52 PM
I would like to make it so that a button highlights when it's selected, and remains highlighted until another is selected.

Any suggestions?

I have tried simply adding to the method that the button invokes to have it remain highlighted, but that doesn't work because UIButton automatically unhighlights itself on touch up after the method it invokes is called.



Darkroom
Dec 10, 2009, 12:56 AM
not sure if it's possible to control the highlight graphics like you want simply with IB. you'll have to roll your own highlight animations that make good use boolean variables, etc. the attached file should help you.

ArtOfWarfare
Dec 10, 2009, 04:47 AM
I found a way to make it work.

The method that the button invokes involves creating a UIPicker. While the picker is finding the titles, it disables and highlights the button. (It disables the button so that touching it won't cause touchup to fire again, thus automatically ending the highlight.)