Tinder like Animation using UIPanGestureRecognizer and Rotation

ios, iphone, objective-c, uigesturerecognizer, uiimageview

Solution

You can do this by listening to touchesBegan, touchesMoved and touchesEnded methods..

Basically this is what you need to do:

- In touchesBegan get the touch point with respect to current view (You will need it later to rotate the image by anchoring at this point).

- In touchesMoved get the touch point with respect to superview and move the view as the touches are moved.

- Apply a small rotation based on the movement using CGAffineTransformMakeRotation

- In touchesEnded either move the view offscreen or set it back to its initial position.

Hope this help.. Check this repo for reference.

Problem

I am trying to implement Tinder like animation to swipe an image to left and right and rotate it while doing so. I have an array of images and need swipe them one after the other. So far I have been able to Use UIPanGestureRecognizer to move the image around but when I try to rotate the image, everything just breaks. I have uploaded the code here. Could someone point me out in the right direction to develop the algorithm and fine tune it to achieve the perfection like Tinder.

Original source