Instagram like pinch to zoom + translation

Trying to use a pinch gesture to move an image like Instagram. Conventional if it was a pan, I would use translation using CGPoints and focus on the presentation.

Currently I can scale like this:

@IBAction func handleShirtsZoom(_ sender: UIPinchGestureRecognizer) {
    self.view.bringSubview(toFront: shirts)
    sender.view?.transform = (sender.view?.transform)!.scaledBy(x: sender.scale, y: sender.scale)
    sender.scale = 1.0
}

      

How do I zoom and pan?

+3


source to share





All Articles