ios图片放大缩小

【ios图片放大缩小】1.设置图片的放大缩小锚点

//两点缩放手势UIPinchGestureRecognizer的响应函数 -(IBAction) pinchGestureHandler:(id)sender { UIPinchGestureRecognizer * pinchGesture = sender; NSLog(@"缩放手势已经响应"); CGFloat scaleValue = https://www.it610.com/article/[pinchGesture scale]; imgView.layer.anchorPoint = CGPointMake(0.5,0.5f); if (scaleValue> 1) {//放大 pinchGesture.view.transform = CGAffineTransformMakeScale(lastScaleValue+(scaleValue-1), lastScaleValue+(scaleValue-1)); }else{//缩小 pinchGesture.view.transform = CGAffineTransformMakeScale(lastScaleValue*scaleValue,lastScaleValue*scaleValue); } if (pinchGesture.state == UIGestureRecognizerStateEnded) { if (scaleValue > 1) { lastScaleValue += (scaleValue-1); }else{ lastScaleValue *= scaleValue; } } } //两点缩放手势 安装函数 -(void) installPinchGesture { UIPinchGestureRecognizer * pinchGesture; //1 构造手势 (注意手势的响应函数) pinchGesture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchGestureHandler:)]; //2 设置手势 //... lastScaleValue = https://www.it610.com/article/1; //成员变量//3 为具体的view添加手势 [imgView addGestureRecognizer:pinchGesture]; }


    推荐阅读