In the ViewController I would like to:
1) Detect if the UIView has been selected
2) Insert an image at the coordinates.
How do I do this? I’m currently using:
CGPoint touchPoint = [touch locationInView:theViewIWant];
UIImage *myImage = [UIImage imageNamed:@"myimage.jpg"];
[myImage drawAtPoint:touchPoint];
But this isn’t working.
The most straightforward way to do what you want is to create a
UIImageViewwhich you insert or remove as a subview when appropriate.However, why go to all that trouble when
UIButtonalready provides this functionality? Just create a button of type UIButtonTypeCustom and set a background image only for the “highlighted” state.