标签:
UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
[imageView addGestureRecognizer:pinchGestureRecognizer];
- (void) handlePinch:(UIPinchGestureRecognizer*) recognizer { recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale); recognizer.scale = 1; }
UIPanGestureRecognizer * panRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePan:)]; //添加手势到 tabBarController.view [tabBarController.view addGestureRecognizer:panRecognizer];
- (void) handlePan:(UIPanGestureRecognizer*) recognizer { CGPoint translation = [recognizer translationInView:self.view]; recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,recognizer.view.center.y + translation.y); [recognizer setTranslation:CGPointZero inView:self.view]; }
/** * 处理旋转手势 * * @param recognizer 旋转手势识别器对象实例 */ - (void)handleRotation:(UIRotationGestureRecognizer *)recognizer
{ recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, recognizer.rotation); recognizer.rotation = 0.0; }
大家需要注意的是,一个手势只能对应一个View, 但是一个View可以有多个手势
标签:
原文地址:http://www.cnblogs.com/CLiOS/p/5351165.html