Using Gesture Recognizers such as Pan, Pinch, and Rotate, is it at all possible to manipulate a UIImage within a UIImageView?
Whenever I try to define the gesture recognizer for the UIImage, I get an error stating
No visible UIImage supports ‘addGestureRecognizer:’
With this code:
UIRotationGestureRecognizer *rotateGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateImage:)];
[imageStrip addGestureRecognizer:rotateGesture];
Is there anyway to transform a UIImage inside of a UIImageView without transforming the UIImageView?
You could add gesture recognizers to any kind of
UIViewand in your event handling methods you could redrawUIImageto a freshly createdCGContextRef. This context would have to be transformed withCGContextRotateCTM,CGContextScaleCTM,CGContextTranslateCTMthat would be called with parameters matching the ones you receive from gesture recognizers. That’s the hard way.Alternatively you could create a scratch
UIImageViewwith your image, transform it with gesture recognizers then render it to aCGContextRefand get the transformed image out of this context.Certainly doable, but not trivial.