i trying make set of views draggable. dragged pan gesture recognizer
view called apps
. current code doesn't work.
@ibaction func moveapp(_ sender: uipangesturerecognizer) { let translation = sender.translation(in: self.view) sender.view!.center = cgpoint(x: sender.view!.center.x + translation.x, y: sender.view!.center.y + translation.y) sender.settranslation(cgpoint.zero, in: self.view) }
you should replace code in ibaction method following code. worked me.
@ibaction func moveapp(_ sender: uipangesturerecognizer) { let point = sender.location(in: view) sender.view?.center = point }
Comments
Post a Comment