上代码
self.imageView.userInteractionEnabled = YES;
//pan手势 移动位置
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];
[self.imageView addGestureRecognizer:pan];
//rotation旋转手势
UIRotationGestureRecognizer * rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotation:)];
rotation.delegate = self;
[self.imageView addGestureRecognizer:rotation];
//pinch捏合手势
UIPinchGestureRecognizer * pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinch:)];
pinch.delegate = self;
[self.imageView addGestureRecognizer:pinch];
- (void)pan:(UIPanGestureRecognizer * )pan{
CGPoint transP = [pan translationInView:self.imageView];
self.imageView.transform = CGAffineTransformTranslate(self.imageView.transform, transP.x, transP.y);
[pan setTranslation:CGPointZero inView:self.imageView];
}
- (void)rotation:(UIRotationGestureRecognizer * )rotation{
self.imageView.transform = CGAffineTransformRotate(self.imageView.transform, rotation.rotation);
rotation.rotation = 0;
}
- (void)pinch:(UIPinchGestureRecognizer * )pinch{
self.imageView.transform = CGAffineTransformScale(self.imageView.transform, pinch.scale, pinch.scale);
pinch.scale = 1;
}