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

button, ios

Solution

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];

Problem

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.

Original source