1.UITapGestureRecognizer Tap/Double-click gesture
Copy Code code as follows:
var tapgesture = UITapGestureRecognizer (target:self, Action: "Handletapgesture:")
Set the number of gestures to click: Click 2
tapgesture.numberoftapsrequired = 2
Self.view.addGestureRecognizer (Tapgesture)
2.UIPinchGestureRecognizer Pinch (zoom/shrink) gesture
Copy Code code as follows:
var pinchgesture = Uipinchgesturerecognizer (target:self, Action: "Handlepinchgesture:")
Self.view.addGestureRecognizer (Pinchgesture)
3.UIRotationGestureRecognizer Rotation gesture
Copy Code code as follows:
var rotategesture = Uirotationgesturerecognizer (target:self, Action: "Handlerotategesture:")
Self.view.addGestureRecognizer (Rotategesture)
4. Uipangesturerecognizer drag gesture
Copy Code code as follows:
var pangesture = Uipangesturerecognizer (target:self, Action: "Handlepangesture:")
Self.view.addGestureRecognizer (Pangesture)
5. Uiswipegesturerecognizer Motion Gesture
Copy Code code as follows:
var swipegesture = Uiswipegesturerecognizer (target:self, Action: "Handleswipegesture:")
Swipegesture.direction = uiswipegesturerecognizerdirection.left//No setting is right
Self.view.addGestureRecognizer (Swipegesture)
6. Uilongpressgesturerecognizer by gesture
Copy Code code as follows:
var longpressgesutre = Uilongpressgesturerecognizer (target:self, Action: "Handlelongpressgesture:")
Long time between
Longpressgesutre.minimumpressduration
The number of touches required
Longpressgesutre.numberoftouchesrequired
Self.view.addGestureRecognizer (Longpressgesutre)
The Uigesturerecognizerstate enumeration is defined as follows
Enum Uigesturerecognizerstate:int {
Case Possible//The recognizer has is not yet recognized its gesture, and but may is evaluating touch events. This is the default state
Case began//the recognizer has received touches recognized as the gesture. The action method would Being called at the next turn of the run loop
case Changed//The recognizer has received touches Gnized as a change to the gesture. The action method is called at the next turn on the run loop
case Ended//the recognizer has Received touches recognized as the end of the gesture. The action method is called at the next turn the run loop and the recognizer would be reset to Uigesturerecognizers Tatepossible
Case cancelled//the recognizer has received touches resulting in the cancellation of The gesture. The action method is called at the next turn the run loop. The recognizer is reset to uigesturerecognizerstatepossible
Case Failed//The recognizer has received a touch sequence which can not be recognized as the gesture. The action method is called and the recognizer is reset to uigesturerecognizerstatepossible
}