ios 实现捏合/双击以缩放 UIImage

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20806265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:54:25  来源:igfitidea点击:

Implementing pinch/double tap to zoom for a UIImage

iosios7uiscrollviewuiimageviewuiimage

提问by StuartM

I am trying to workout how to implement a UIImagethat has pinch/double tap to zoom. Is this possible with a standard UIImageView?

我正在尝试练习如何实现UIImage捏合/双击缩放。这可以用标准UIImageView吗?

Looking at other questions at documentation it has to be completed with a UIScrollView?

查看文档中的其他问题,它必须以UIScrollView?

Source: https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/ZoomingByTouch/ZoomingByTouch.html

来源:https: //developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/ZoomingByTouch/ZoomingByTouch.html

The issue I see is that the above link suggests using initWithImageon the scrollView, but that is not available?

我看到的问题是上面的链接建议initWithImage在 scrollView 上使用,但这不可用?

I am looking to implement an Image that is full screen (no larger), if the image is larger it should scale Aspect to Fit into the full screen. The user can then double tap or Pinch to zoom into the image. What is the correct approach for this?

我希望实现一个全屏(不更大)的图像,如果图像更大,它应该缩放 Aspect 以适应全屏。然后用户可以双击或捏合来放大图像。什么是正确的方法?

回答by dreamzor

Never try to zoom an image itself - it consumes just too muchtime. Instead, as you've mentioned, zoom the view. It can be made with UIScrollViewusing almost default parameters.

永远不要尝试缩放图像本身 - 它消耗太多时间。相反,正如您所提到的,缩放视图。它可以UIScrollView使用几乎默认的参数来制作。

Here is how: How to zoom in/out an UIImage object when user pinches screen?

方法如下:如何在用户捏合屏幕时放大/缩小 UIImage 对象?