开发者

Is there a way to get the center point of the touches when zooming a UIScrollView?

开发者 https://www.devze.com 2023-02-18 08:33 出处:网络
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 ta

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消