Simulate UIScrollView Deceleration

ios, objective-c, uigesturerecognizer, uiscrollview

Solution

Session 223 at WWDC 2012, "Enhancing User Experience With Scroll Views", covered a method to use a scrollview's behavior and "feel" to animate the position of a different view (without the scrollview ever actually being visible to the user).

The benefit of the method shown in the session is that your deceleration would always match UIScrollView's, now and forever.

https://developer.apple.com/videos/wwdc/2012/?id=223

Problem

I have an `UIPanGestureRecognize` which I use to change the frame of a view. Is there a way to simulate the deceleration of the `UIScrollView` or `UITableView` when the gesture's state is `UIGestureRecognizerStateEnded`? Here is my current code: ``` if (panGesture.state == UIGestureRecognizerStateEnded) { [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{ self.view.frame = CGRectMake(182, 0, self.view.frame.size.width, self.view.frame.size.height); } completion:^(BOOL finished) { if (finished) { //Do something } }]; } ``` but this is not a smooth scroll. I would like something that decelerates until it stops to the point I've set. Thanks

Original source