I created a button on my view controller which has a predefined background image. I created an action and an outlet for this button. I want when the user taps the button to change the background image of this button. How can i do that?
I tried to put into the action method of the button something like this:
snapshotCheckbox.image = [UIImage imageNamed:@"snapshot.png"];
but i guess this method is for UImageViews. How can i do the same thing for a button?
Thank you very much for reading my post 😀
One solution to do this would be to display the image in a
UIImageViewand put a transparent UIButton on top of the UIImageView. In Interface Builder you can change a UIButton to “custom”.This would allow you to change the image displayed in the UIImageView easily when handling the action triggered when the UIButton is pushed.
Hope this helps.