//平移
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
[myView addGestureRecognizer:pan];
//缩放
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];
[myView addGestureRecognizer:pinch];
//旋转
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotation:)];
[myView addGestureRecognizer:rotation];
}
//旋转
- (void)rotation:(UIRotationGestureRecognizer *)traget {
UIView *myView = traget.view;
myView.transform = CGAffineTransformMakeRotation(traget.rotation);
}
//平移
- (void)pan:(UIPanGestureRecognizer *)traget {
UIView *myView = traget.view;
CGPoint point = [traget translationInView:self.view];
myView.center = CGPointMake(myView.center.x + point.x, myView.center.y
+ point.y);
[traget setTranslation:CGPointZero inView:self.view];
}
//缩放
- (void)pinch:(UIPinchGestureRecognizer *)traget {
UIView *myView = traget.view;
myView.transform = CGAffineTransformMakeScale(traget.scale, traget.scale);
// myView.transform = CGAffineTransformScale(myView.transform, traget.scale, traget.scale);
// traget.scale = 1;
}