我想要通過UIPinchGestureRecognizer
來對圖片操作,但是代碼運行之後不是很理想,而且不能縮放
代碼如下:
-(void) pinching: (UIPinchGestureRecognizer *) sender {
CGAffineTransform myTransformation =
CGAffineTransformMakeScale(sender.scale, sender.scale);
sender.view.transform = myTransformation;
}
- (void)viewDidLoad
{
UIPinchGestureRecognizer *pinch =
[[UIPinchGestureRecognizer alloc]
initWithTarget:self
action:@selector(pinching:)];
pinch.delegate = self;
[imageBG addGestureRecognizer:pinch];
[imageBG setUserInteractionEnabled:YES];
[imageBG setMultipleTouchEnabled:YES];
}
把UIImageView放到一個UIScrollView裡,並實現UIScrollVIew的代理方法viewForZoomingInScrollView返回UIImageVIew
UIScrollView還需要設置一下maximumZoomScale.