Can anyone tell me how to change UIButton background image?I have a CustomtableView which is holding 4 buttons.It's like a quiz app.I want to show if the ans is correct or not loading two background image.If correct a green image and if wrong a red image.
And when another question is loaded.Reset them.It should happen in the click.I am done with all the loading functionality and logical task of score counting.I just need t开发者_JAVA技巧o change the button background image.Can anyone tell me how to do this?
You should be able to do that just calling
[button setImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal];
or alternatively
[button setBackgroundImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal];
Documentation reference:
setImage:forState:
setBackgroundImage:forState:
精彩评论