Pinches are a two fingered gesture where the fingers move closer or farther from each other. This gesture is generally used for resizing a view.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// Pinch
let pinchGesture = UIPinchGestureRecognizer(target: self, action: #selector(handlePinch(_:)))
pinchView.addGestureRecognizer(pinchGesture)
}
// Pinch action
func handlePinch(gesture: UIPinchGestureRecognizer) {
label.text = "Pinch recognized"
if gesture.state == UIGestureRecognizerState.Changed {
let transform = CGAffineTransformMakeScale(gesture.scale, gesture.scale)
pinchView.transform = transform
}
}