damacri86
damacri86

Reputation: 295

iOS drag objects with inertia

I am starting with gestures in iOS and I don't know how add inertia to my movements. Exactly in pan gestures.

In that moment I can move objects with this type of recognizer but I want a little system of physic similar to the effect of the scrolls view.

Someone can help me? Thank you very much

Upvotes: 4

Views: 1790

Answers (1)

Ash Furrow
Ash Furrow

Reputation: 12421

When you're using a UIPanGestureRecognizer, you have translationInView: and velocityInView:. velocity is the speed at which the user is moving their finger, in pixels/second. You can use the velocity to do find out the inertia the user "gives" the view when their finger is liften (the recognizer's state is UIGestureRecognizerStateEnded).

Upvotes: 5

Related Questions