我有一个实现,其中我将UIImageView子类化,并将其称为“ DraggableImage”
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { originalPosition = self.center }override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { if let touch = touches.first { let position = touch.location(in: self.superview) self.center = CGPoint(x: position.x, y: position.y) } }override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { self.center = originalPosition }


