我尝试放大单击 UIImageView 中的图像女巫的区域。我使用 CGAffineTransformMakeScale 进行缩放,并更改了 imageView.layer.anchorPoint 与单击的点坐标缩放正在工作,但图像不再位于中心,我认为我在 anchorPoint 坐标上错了,我发现很多文章都在讨论它,但是太复杂了
请帮忙 !
代码:
-(void)gestureTapEvent:(UITapGestureRecognizer *)gesture {
NSLog(@"doubleclic");
CGPoint touchPoint = [gesture locationInView:gesture.view];
NSLog(@"Position of touch: %.3f, %.3f", touchPoint.x, touchPoint.y);
float newX = touchPoint.x/imageView.frame.size.width;
float newY = touchPoint.x/imageView.frame.size.height;
imageView.transform = CGAffineTransformMakeScale(1.5, 1.5);
imageView.layer.anchorPoint = CGPointMake(newY, newX);
}