How can I change the background image of my UIButton in click event? And refresh it in a few second with the previous image? I mean change it's background image on click and reset it after the click.
[yourButton setImage:[UIImage imageNamed:@"yourNormalImage.png"] forState:UIControlStateNormal];
[yourButton setImage:[UIImage imageNamed:@"yourImageWhenClicking.png"] forState:UIControlStateHighlighted];
put your clickEvent image as highlighted image of your button..
The above answer is not working because it doesn't change the background but the side image of the UIButton
, to change the background image use:
[yourButton setBackgroundImage:[UIImage imageNamed:@"yourimage"] forState:UIControlStateNormal];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With