开发者

iPhone iOS: How to dynamically move around/resize images on top of an image background?

开发者 https://www.devze.com 2023-03-18 15:04 出处:网络
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

I am interested in developing an app that allows a user to do the following:

  1. Set a background image
  2. Add images on top of the background image
  3. Allow user to move the images around by touching and dragging
  4. 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:

  1. Display a single image on the screen.
  2. Move it with one finger.
  3. Zoom it with two fingers (use a gesture recogniser).
  4. Rotate it with two fingers.
  5. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消