I am interested in developing an app that allows a user to do the following:
- Set a background image
- Add images on top of the background image
- Allow user to move the images around by touching and dragging
- Allow use开发者_开发技巧r to rotate/scale these images
Specifically, I am interested in knowing how to detect a touch in one of the images that get added on top of the background image, how to detect which image is being touched so that it can be manipulated, maintain z-order, etc.
What's the best way to go about doing this? Any sample code out there?
I suggest you tackle this in bite-sized chunks:
- Display a single image on the screen.
- Move it with one finger.
- Zoom it with two fingers (use a gesture recogniser).
- Rotate it with two fingers.
- Add a second image.
It should be quite easy to find tutorials for each of these elements. It's your job to put it all together.
You can find the view which touched like
//backgroundImageView should be declared in header file
if([touch view] != backgroundImageView && [[touch view] isKindOfClass:[UIImageView class]]) {
//You have touched imageView on top of background imageview
}
I hope now you have got an "IDEA".
Also search on google and stackoverflow you will find many samples about it.
精彩评论