// 处理缩放手势
- (void) pinchView:(UIPinchGestureRecognizer *)pinchGestureRecognizer
{
NSLog(@"---%ld",pinchGestureRecognizer.state);
NSLog(@"=====%f",pinchGestureRecognizer.scale);
UIView *view = pinchGestureRecognizer.view;
if (pinchGestureRecognizer.state == UIGestureRecognizerStateBegan || pinchGestureRecognizer.state == UIGestureRecognizerStateChanged)
{
if (view.transform.a<_oldTransform.a/2||view.transform.a>_oldTransform.a*3) {
return;
}
view.transform = CGAffineTransformScale(view.transform, pinchGestureRecognizer.scale, pinchGestureRecognizer.scale);
pinchGestureRecognizer.scale = 1;
}
if (pinchGestureRecognizer.state ==UIGestureRecognizerStateEnded||pinchGestureRecognizer.state==UIGestureRecognizerStateCancelled||pinchGestureRecognizer.state== UIGestureRecognizerStateFailed)
{
if (view.transform.a < _oldTransform.a) {
[UIView animateWithDuration:.3 animations:^{
_imageView.transform = CGAffineTransformScale(_oldTransform, 1, 1 );
}];
}else if (view.transform.a>_oldTransform.a*2){
[UIView animateWithDuration:.3 animations:^{
_imageView.transform = CGAffineTransformScale(_oldTransform, 2,2 );
}];
}
}
}