我可以让捏/缩放功能像这样工作:
- (void)twoFingerPinch:(UIPinchGestureRecognizer *)recognizer
{
if([recognizer state] == UIGestureRecognizerStateBegan) {
_lastScale = 1.0;
}
CGFloat scale = 1.0 - (_lastScale - [recognizer scale]);
CGAffineTransform currentTransform = self.imageForEditing.transform;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, scale, scale);
[self.imageForEditing setTransform:newTransform];
_lastScale = [recognizer scale];
}
问题是图像会根据其中心进行缩放,因此如果您首先平移图像使其不居中,然后捏合/缩放,它不会放大到触摸之间的区域。我认为这一定是一个已经解决和解决的常见问题,但我一直无法找到解决方案。