2010-09-29 44 views

回答

6

你要附加一個UIPanGestureRecognizer的形象和時的動作方法被調用時,你可以要求手勢的當前翻譯和速度。然後根據這些值旋轉圖像。由於這是一個連續的手勢,當平移手勢發生變化時會通知您,允許您更新圖像的旋轉。

UIPanGestureRecognizer Class Reference

-

更新

我重讀你的問題,如果你想通過做典型的旋轉手勢來旋轉用你的手指圖像,你應該使用UIRotationGestureRecognizer而不是UIPanGestureRecognizer。如果你想做一個平移手勢左右移動你的手指,你將不得不使用UIPanGestureRecognizer。我只想完成答案。

添加的旋轉手勢識別:

UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)]; 
[self.myView addGestureRecognizer:rotationRecognizer]; 
[rotationRecognizer release]; 

處理的手勢和所述圖像相應地旋轉可能看起來像這樣(在其最簡單的形式):

- (void)handleGesture:(UIRotationGestureRecognizer *)sender { 
    self.myView.transform = CGAffineTransformMakeRotation(sender.rotation); 
} 
+0

感謝的Yannick:d – awlcs 2010-09-30 15:04:30

相關問題