Change a UIImage programmatically [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this开发者_C百科 questioni have 2 UIImages
and a UISwitch
, when the switch is on, image 1 appear and when the switch is off the image 2 appear... any ideas?
If you have a UISwitch called myUISwitch and a UIImageView called myUIImageView:
if(myUISwitch.on) {
[myUIImageView setImage:[UIImage imageNamed:@"myOnImage.png"]];
}
else {
[myUIImageView setImage:[UIImage imageNamed:@"myOffImage.png"]];
}
You can put this code in the function triggered by changing the UISwitch...
精彩评论