我有一个图像视图,想添加一些自定义捏合手势识别器。我可以缩放我的图像视图,但问题是,它不是从两个手指的中心放大。
如何从两个手指的中心进行缩放?这就是我目前正在做的(在viewDidLoad
)
UIPinchGestureRecognizer* pinchRecognizer =
[[UIPinchGestureRecognizer alloc] initWithTarget:self
action:@selector(handlePinch:)];
[imageView addGestureRecognizer:pinchRecognizer];
这是捏法的代码
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer
{
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
recognizer.scale = 1;
}
感谢代表们...现在我在这里更新我的问题..我想在按钮单击时缩放图像..我正在做的是
-(IBAction)Zoom_image:(id)sender {
CGFloat scaleValue = 2;
CGAffineTransform transform = GAffineTransformMakeScale(scaleValue,scaleValue);
self.backgroundImgView.transform = transform;
}