简体   繁体   中英

What's the point of view parameter of translation(in:) func of UIPanGestureRecognizer?

Better late than never.

UIPanGestureRecognizer has a translation(in:) func with view parameter. Does someone know why it parameter there?

I've tried different values of this parameter - nil, window, superview, view but the func always returns the same value. Is there some case when it different?

Regarding apple documentation view parameter is The view in whose coordinate system the translation of the pan gesture should be computed. So, what does it mean?

Just in case it works fine. Usually I use view as a parameter that has pan gesture but I want to know:)

UPD: Same situation with velocity(in:) parameter of UIPanGestureRecognizer.

The reason you're not seeing any difference is that a point is a point for all the views you've checked.

But now add to your interface a view whose transform is a CGAffineTransform scale transform and use that to check the value of translation(in:) . You'll see a difference!

So you can see why specifying the view might matter. This whole thing could be taking place in a world (or a portion of the world) to which a scale transform has been applied, and in that case you'd want the answer in an appropriate point scale.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM