UIPinchGestureRecognizer 将捏合视图定位在两根手指之间
我成功地实现了视图的捏合缩放。然而,视图并没有位于我希望的位置。对于 iPad 上的 stackoverflowers,我希望我的视图能够像 iPad Photos.app 一样居中:当您捏合并缩放相册时,照片会以不断扩展的视图呈现。该视图大致以第一根手指的右上角和另一根手指的左下角为中心。我将它与平移识别器混合在一起,但这样用户总是需要捏合,然后平移进行调整。
这里有非常图形化的解释,如果不清楚的话我可以发布我的应用程序的视频(这不是秘密,我正在尝试重现 iPad 的 Photos.app...)
因此,对于手指的初始位置,开始缩放:
这是目前实际的“缩放”框架。正方形更大,但位置在手指下方
这是我想要的:相同大小,但 origin.x 和 y 不同:
(抱歉我的 Photoshop 技巧很差 ^^)
I successfully implemented a pinch a zoom of a view. However, the view doesn't position itself where I wished it to be. For the stackoverflowers with an iPad, I would like my view to be centered like on the iPad Photos.app : when you pinch&zoom on an album, the photos present themselves in a view that is expanding. This view is approximately centered with the top right hand corner on the first finger and the bottom left hand finger on the other finger. I mixed it with a pan recognizer, but this way the user always has to pinch, and then pan to adjust.
Here are so graphic explanation, I could post a video of my app if that's unclear (no secret, i'm trying to reproduce the Photos.app of the iPad...)
So for an initial position of the fingers, begining zooming :
This is the actual "zoomed" frame for now. The square is bigger, but the position is below the fingers
Here is what I would like to have : same size, but different origin.x and y :
(sorry about my poor photoshop skills ^^)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过
handlingPinchGesture
方法中的以下代码获取两根手指之间的中点的CGPoint
。我的整个
handlePinchGesture
方法如下。You can get the
CGPoint
of the midpoint between two fingers via the following code in the methodhandlingPinchGesture
.My whole
handlePinchGesture
method is below.查看 Touches 示例项目。具体来说,这些方法可以帮助您:
Have a look at the Touches sample project. Specifically these methods could help you: