iOS 开发中手势方法的使用

  • 以下使用方法能够较好的控制手势
- (void)pinchGestureDetected:(UIPinchGestureRecognizer *)recognizer  
{  
    UIGestureRecognizerState state = [recognizer state];  
      if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStateChanged)  
    {  
        CGFloat scale = [recognizer scale];  
        [recognizer.view setTransform:CGAffineTransformScale(recognizer.view.transform, scale, scale)];  
        [recognizer setScale:1.0];  
    }  
}  
- (void)rotationGestureDetected:(UIRotationGestureRecognizer *)recognizer  
{  
    UIGestureRecognizerState state = [recognizer state];  
      
    if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStateChanged)  
    {  
        CGFloat rotation = [recognizer rotation];  
        [recognizer.view setTransform:CGAffineTransformRotate(recognizer.view.transform, rotation)];  
        [recognizer setRotation:0];  
    }  
}  
- (void)panGestureDetected:(UIPanGestureRecognizer *)recognizer  
{  
    UIGestureRecognizerState state = [recognizer state];  
      
    if (state == UIGestureRecognizerStateBegan || state == UIGestureRecognizerStateChanged)  
    {  
        CGPoint translation = [recognizer translationInView:recognizer.view];  
        [recognizer.view setTransform:CGAffineTransformTranslate(recognizer.view.transform, translation.x, translation.y)];  
        [recognizer setTranslation:CGPointZero inView:recognizer.view];  
    }  
}

你可能感兴趣的:(iOS 开发中手势方法的使用)