Question

In my app I allow for a user to pick an image and then select other images to layer over the top of the main image. I then implement gesture Recognizers to pinch, pan and rotate the top images.

For example, a user could select an image of a person and then select a pair of sunglasses to overlay over the top of the image and pinch, pan or rotate them into place.

This works great but as the overlayed image gets smaller it becomes harder for the user to size, pan or rotate.

I'm looking to implement some functionality that I've seen on a similar app where they allow for this to be controlled by a pinch/rotation handler on the corner of the top UIImageView. I can't seem to figure this out. I've attached a screenshot of the app that currently does this that I'm trying implement. Any suggestions would help. Thank you.

enter image description here

Was it helpful?

Solution 3

I finally was able accomplish this by using this control. https://www.cocoacontrols.com/controls/tdresizerview

OTHER TIPS

The simplest way is to set the frame size of the corner images some more larger than the image size and set the content into centre.

For Eg:

image size is 30x30 means set the frame size as 40x40 and set the image as centre of the view like,

iconImgView.contentMode = UIViewContentModeCenter;

Hope it will helps you.

The easiest way to do this is just adding the gesture recognizer into that small “rotate“ image. It will then receive touches only withing its bounds.

Another option would be to use delegate methods and allow receiving touches in desired frame manually, but this is not good in your case, because:

  • normal rotate gesture (UIRotationGestureRecognizer) is different than this “drag-the-corner-to-rotate” gesture, which is simple UIPanGestureRecognizer
  • your “rotate” image is partially outside of the frame of the “sunglases” image, so you would need to add the gesture to parent maybe and this would be more complicated
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top