UIImageView点击放大的UIScrollView
问题描述:
我用UIImageView建立一个应用程序,我搜索了网络,但找不到一个完整的解决方案没有一个UIScrollView来做我的看法的点击放大。UIImageView点击放大的UIScrollView
这是我现在有,但它不能很好地工作:
这是可能的吗?如果有更好的方法来做到这一点,我愿意帮助你。
在viewDidLoad中:
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTap setNumberOfTapsRequired:2];
[imageViewForCrop addGestureRecognizer:doubleTap];
我把手枪王方法:
- (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);
}
答
尝试使用变换。这将使图像看起来是原始图像的两倍。
- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
imageViewForCrop.transform = CGAffineTransformMakeScale(2.0, 2.0);
}
+1
它运作良好,我如何才能到达按下屏幕的图像?因为现在图像不会被水龙头中心保存下来。 – 2015-02-09 06:55:14
+0
图像包含在'UIImageView'中。但是,图像没有改变。你想保存转换后的图像吗? – bbarnhart 2015-02-09 12:36:33
要放大以查看此照片的更多信息,或者只是稍微大一些? – bbarnhart 2015-02-08 13:37:19
只是在用户点击的位置变大。 – 2015-02-08 13:49:47
您是否想要放大用户点击的位置,或者只是使其变大一点? – 2015-02-08 16:37:58