有没有办法在缩放 UIScrollView 时获取触摸的中心点?
我可以缩放 UIScrollView,但不确定是否可以使内容从触摸的中心点缩放(因此更自然)。默认情况下,它只是通过缩放来缩放,而不考虑两个手指的中心。
我熟悉手势识别器,如果不可能的话,我会使用它们。只是想知道我是否错过了什么。
I can zoom a UIScrollView, but not sure if it's possible to cause the content to zoom from the center point of the touches (so it's more natural). By default it just zooms by scaling and does not take the center of the two fingers into account.
I'm familiar with gesture recognizers, and will use those if this isn't possible. Just wanted to know if I missed something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我的一个应用程序中做了类似的事情。我只处理触摸事件。如果跟踪每个触摸个体,您可以从数学上找到触摸的中心点。然后,您可以进行标准缩放,并且还可以使用滚动视图的内容偏移属性,即使在缩放后也可以将触摸的中心点保持在同一位置。关键是确定坐标本身的缩放将如何导致“中心点”移动,然后手动将其移回该量。
I did something similar to this in one of my applications. I did just with the touch events. If you track each touch individual, you can mathematically find the center point of the touches. Then you can do the standard zooming, and also use the content offset properties of the scroll view to keep the center point of the touches in the same place even after the zooming. The key is determining how the scaling of the coordinates themselves will cause the "center point" to move, and then manually moving it back that amount.