views:

70

answers:

1

How set image in button when ever click the button image show me that button run.backgroundColor = [UIColor redColor] I try this but it doesn't work,

+1  A: 

To set an image for a button while it is currently being touched (I think this is what you're asking). You use setImage: forState on the UIButton.

[myButton setImage:[UIImage imageNamed:@"myButtonGraphic.png"] forState:UIControlStateHighlighted];

You can control when the image appears using the different control states, one of:

UIControlStateNormal

UIControlStateHighlighted

UIControlStateDisabled

UIControlStateSelected

UIControlStateApplication

UIControlStateReserved

If you use UIControlStateNormal, the image is displayed all the time, and when the button is currently being touched it will appear dimmer which for a lot of cases is good enough to indicate to the user that they are selecting that button and that it's a real touchable 'thing'.

mbehan