If you can already implement the basics with gestures, then you are almost there!
Honestly, although I did just that in my application, I use old-fashioned strokes of Began, touchhesMoved, etc.
In terms of gestures, you will need to use the UIPanGestureRecognizer so that you can fully control the drag and drop. UISwipeGestureRecognizer recognizes only swipes.
In any case, after a certain moment, you simply translate the panel only part of the distance that the person was dragging.
CGRect newPanelFrame = panel.frame; if (newPanelFrame.origin.y + dragOffset > 275) { newPanelFrame.origin.y += dragOffset / 2.0; } panel.frame = newPanelFrame;
In touchesEnded:withEvent: or if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
CGRect newPanelFrame = panel.frame; if (newPanelFrame.origin.y > 275) { newPanelFrame.origin.y = 275; } panel.frame = newPanelFrame;
The reason I never bothered with UIPanGestureRecognizer is because I could never figure out how to get a non-cumulative translation (translationForView: cumulative), which is necessary if you want to significantly slow down drag and drop after the threshold.
source share