【问题标题】:UIImageView tap to zoom in witout UIScrollViewUIImageView 点击放大而不使用 UIScrollView
【发布时间】:2015-02-08 13:16:05
【问题描述】:

我用 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);

}

【问题讨论】:

  • 您想放大以查看图像的更多细节还是将其放大?
  • 只是在用户点击的地方变大。
  • 你想放大用户点击的点还是无论如何都放大?
  • 想要在用户点击的地方放大。

标签: objective-c uiimageview uipangesturerecognizer


【解决方案1】:

尝试使用转换。这将使图像视图的大小是原始视图的两倍。

- (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer {
    imageViewForCrop.transform = CGAffineTransformMakeScale(2.0, 2.0);
}

【讨论】:

  • 效果很好,我如何才能看到我按下屏幕的图像?因为现在图像在没有通过点击中心保存的情况下增长。
  • 图片包含在UIImageView中。然而,图像并没有改变。您要保存转换后的图像吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-15
  • 1970-01-01
  • 2012-02-12
  • 1970-01-01
  • 1970-01-01
  • 2018-04-17
相关资源
最近更新 更多