我几乎正在尝试找到一种可以在应用程序中同时缩放和旋转图像的方法。
我发现这段代码指示我将其放入 TouchMoved 方法中:
UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];
UITouch *touch2 = [[allTouches allObjects] objectAtIndex:1];
CGPoint previousPoint1 = [touch1 previousLocationInView:nil];
CGPoint previousPoint2 = [touch2 previousLocationInView:nil];
CGFloat previousAngle = atan2 (previousPoint2.y - previousPoint1.y, previousPoint2.x - previousPoint1.x);
CGPoint currentPoint1 = [touch1 locationInView:nil];
CGPoint currentPoint2 = [touch2 locationInView:nil];
CGFloat currentAngle = atan2 (currentPoint2.y - currentPoint1.y, currentPoint2.x - currentPoint1.x);
transform = CGAffineTransformRotate(transform, currentAngle - previousAngle);
self.view.transform = transform;
现在这仅适用于用两根手指旋转,但我也需要能够使用两根手指同时缩放。我已经尝试了一切,但我只是不确定出了什么问题或如何从这里开始。
无论如何, map 应用程序会执行类似的操作,您可以放大 map 并同时旋转它,这就是我试图在应用程序中的图像上实现的目标。
无论如何,从现在开始我该怎么办?
谢谢!
最佳答案
添加UIPinchGestureRecognizer和 UIRotationGestureRecognizer根据您的观点,设置其委托(delegate)并实现以下委托(delegate)函数。
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
应该可以了。
关于ios - 用两根手指旋转和缩放?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17183504/