Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Custom Button's Image when Tapping in iOS?

Tags:

button

ios

I used custom button with Image. In normally , When we tapping button , the color of button has been changed.

When i tapping that custom button , i want to change image from custom button.

How can i change it?

Thanks.

like image 922
Fire Fist Avatar asked Dec 05 '22 16:12

Fire Fist


1 Answers

assuming this is a standard UIButton, you can do the following when initializing the button:

[btnObj setImage:[UIImage imageNamed:@"imgName.png"] forState:UIControlStateHighlighted];

or for the Background image:

[btnObj setBackgroundImage:[UIImage imageNamed:@"imgName.png"] forState:UIControlStateHighlighted];
like image 158
Jose Rafael Santiago Jr. Avatar answered Dec 27 '22 13:12

Jose Rafael Santiago Jr.