我使用UIImageView构建了一个应用程序,我在网上搜索但是在没有UIScrollView的情况下无法找到一个完整的解决方案来在我的视图中点击缩放。
这就是我现在所拥有的,但效果不好:
有可能吗?如果有更好的方法,我很乐意帮助你。
在viewDidLoad中:
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[imageViewForCrop addGestureRecognizer:doubleTap];
我的手柄Double Tap方法:
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint tappedPoint = [gestureRecognizer locationInView:self.view];
CGFloat xCoordinate = tappedPoint.x;
CGFloat yCoordinate = tappedPoint.y;
// zoom in
[imageViewForCrop setFrame:CGRectMake( imageViewForCrop.frame.origin.x , imageViewForCrop.frame.origin.y , imageViewForCrop.frame.size.width +200, imageViewForCrop.frame.size.height+200)];
imageViewForCrop.center = CGPointMake(xCoordinate , yCoordinate);
}
答案 0 :(得分:1)
尝试使用转换。这将使图像视图的大小是原始图像的两倍。
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
imageViewForCrop.transform = CGAffineTransformMakeScale(2.0, 2.0);
}