Two fingers rotating around a center can be listened for with the UIRotationGestureRecognizer
. This is generally used for rotating a view.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// Rotate
let rotateGesture = UIRotationGestureRecognizer(target: self, action: #selector(handleRotate(_:)))
rotateView.addGestureRecognizer(rotateGesture)
}
// Rotate action
func handleRotate(gesture: UIRotationGestureRecognizer) {
label.text = "Rotate recognized"
if gesture.state == UIGestureRecognizerState.Changed {
let transform = CGAffineTransformMakeRotation(gesture.rotation)
rotateView.transform = transform
}
}