UIPinchGestureRecognizer – tap the screen with two fingers and spread them in different directions, so you can increase the scope of the object, slide the finger together again and so you reduce the area.
For example: we need to increase the scope of the picture to see it closer.
We create the UIImageView, which we assign to our picture:
imageView.image = UIImage (named: “cat”)
Create a UIPinchGestureRecognizer, which assigns the function myPinchTap:
pinchGesture = UIPinchGestureRecognizer (target: self, action: # selector (self.myPinchTap))
In the function myPinchTap, we assign the change in the size of the area:
@objc func myPinchTap (recognizer: UIPinchGestureRecognizer) {
self.view.bringSubview (toFront: imageView)
recognizer.view? .transform = (recognizer.view? .transform) !. scaledBy (x: recognizer.scale, y: recognizer.scale)
recognizer.scale = 1.0
And in the end we write Pinch:
imageView.addGestureRecognizer (pinchGesture)


Swift Programming

Apple Xcode