Apalumbo
Apalumbo

Reputation: 25

how to change a custom buttons image when the button is pressed

I'm making a new app, and for one of my modes i want to change the image of a custom button by pressing the button.i have this custom button setup with an image, and i want to change the image when i press the button. any tips?

Upvotes: 1

Views: 92

Answers (1)

gvuksic
gvuksic

Reputation: 3013

In Interface Builder select your button, in Attributes inspector change State Config to "Highlighted" and now you can define highlighted image (along with some other properties).

Via code:

[yourButton setImage:[UIImage imageNamed:@"button-h.png"] forState:UIControlStateHighlighted];

Upvotes: 2

Related Questions