Skip to content

Instantly share code, notes, and snippets.

@tiagomartinho
Created June 28, 2018 10:40
Show Gist options
  • Save tiagomartinho/161449f63dea30bf5ef708eae674dc4e to your computer and use it in GitHub Desktop.
Save tiagomartinho/161449f63dea30bf5ef708eae674dc4e to your computer and use it in GitHub Desktop.
@objc func didPanView(sender: UIPanGestureRecognizer) {
let viewToMove = sender.view!
view.bringSubview(toFront: viewToMove)
let translation = sender.translation(in: view)
let newCenter = CGPoint(x: viewToMove.center.x + translation.x, y: viewToMove.center.y + translation.y)
viewToMove.center = newCenter
sender.setTranslation(CGPoint.zero, in: view)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment