Quote:
Originally Posted by magmo
Hi
I would like to change the color of a button that is being pressed from default blue to grey instead, but it should only be grey when being pressed not when it go back to normal state, how can I do that?
|
There is no easy way to change the color when the button is pressed.
What you can do is install an image for the highlighted state (using the UIButton method setImage:forState

You will probably need to set the button type to custom, and use images for both the normal state and the highlighted state.
There's another trick you can use to make button background images that size themselves to the button size automatically. Use the UIImage method stretchableImageWithLeftCapWidth:topCapHeight: (or, for iOS 5.0 and later, use resizableImageWithCapInsets

Those methods will take an image and convert it to a stretchable image that resizes itself to fit the available space.