觸控手勢
- tap 點
- long tap 長點
- pinch 擠
- rotate 轉
- swipe 掃
- pam 移動
- edge 邊緣
- 底層view 的辨認器上有另一個view時,若上層view沒有gestrue事件底層的會往上透
- gesture
Tap Gesture Recognizer
- Taps : 敲幾下觸發
- Touches : 幾根手指觸控才觸發
Long press Gesture
- Min Duration : 最少按幾秒
- Taps : 無效
- Touches :幾根手指觸控才觸發
Swipe Gesture
- Swipe : 掃的方向
- Touches : 幾根手指觸控才觸發
- 要有幾個方向就加幾個
pen Gesture
- UIView 必須要打開 User Interaction Enabled 才會互動
- 移動ImageView 會一直回傳移動值所以會一直疊加, 所以必須收到一次後就要改變UIView的位置
- (IBAction)handlePan:(UIPanGestureRecognizer *)sender { CGPoint p = [sender translationInView:sender.view]; NSLog(@"%@", NSStringFromCGPoint(p)); mill.center = CGPointMake(mill.center.x+p.x, mill.center.y+p.y); //把當下的點設成原點 [sender setTranslation:CGPointZero inView:sender.view]; }
Pinch
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)sender { // sender.view.transform =CGAffineTransformMakeScale(sender.scale, sender.scale); sender.view.transform = CGAffineTransformScale(sender.view.transform, sender.scale, sender.scale); [sender setScale:1.0]; }
Rotate
- (IBAction)handleRotate:(UIRotationGestureRecognizer *)sender { // sender.view.transform = CGAffineTransformMakeRotation(sender.rotation); sender.view.transform = CGAffineTransformRotate(sender.view.transform, sender.rotation); [sender setRotation: 0.0]; }
留言
張貼留言