您需要将a附加UIPanGestureRecognizer
到图像,并且在调用操作方法时,您可以询问手势的当前平移和速度.然后,您可以根据这些值旋转图像.由于这是一个连续的手势,当平移手势发生变化时,您将收到通知,允许您更新图像的旋转.
-
更新
我已经重读了你的问题,如果你想通过做一个典型的旋转手势用手指旋转图像,你应该使用UIRotationGestureRecognizer
而不是UIPanGestureRecognizer
.如果你想做一个向左或向右移动手指的平移手势,你确实必须使用一个UIPanGestureRecognizer
.我只是想完成答案.
添加旋转手势识别器:
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
[self.myView addGestureRecognizer:rotationRecognizer];
[rotationRecognizer release];
Run Code Online (Sandbox Code Playgroud)
处理手势并相应地旋转图像可能看起来像这样(最简单的形式):
- (void)handleGesture:(UIRotationGestureRecognizer *)sender {
self.myView.transform = CGAffineTransformMakeRotation(sender.rotation);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3209 次 |
最近记录: |