Latest 0.2.1
Homepage https://github.com/Ekulelu/RYGestureRecognizer
License Apache-2.0
Platforms ios 8.0
Authors

This a class can recognize gestures like tap, pan, swipe, pinch, rotation. In system gesture, once you register the tap gesture, the pan gesture will not call the action if the finger doesn’t move a range. And if you want to recognize some gestures at the same time, you should register all these gesture recognizers. But you just register this class, you can recognize almost all gesture, except the "UIScreenEdgePanGestureRecognizer".

You can choose the gesture you want to recognize, just set the property of "gestureEnable" with values in the NS_OPTION "RYGestureEnable".

And in the system gesture, if you register single tap and double tap in the same time, the single tap will be recognized with some delay, in RYGestureRecognizer, the delay is less than the system’s. which is controll by the property of "mutilClickedSensitivity".

You can also add your custom swipe gesture to RYGestureRecognizer, like gesture up-left-down-right. you just call the method "- (void) addCustomGesture:(NSUInteger) customGesture" with unsign integer paramter of 1324.

Install with pod

pod 'RYGestureRecognizer', '~> 0.1.0'

How to use it

//initialize and set the action.
RYGestureRecognizer* recognizer = [[RYGestureRecognizer alloc] initWithTarget:self action:@selector(gestureAction:)];
//recognizer single and double taps.
recognizer.maxNumberOfTapsRequired = 2;
//recognize all supported gestures except the long press gesture. See more detail in header file.
recognizer.gestureEnable ^= RYGestureEnableLongPress; 
//add to the view
[self.view addGestureRecognizer:recognizer]; 

The action method

- (void) gestureAction:(RYGestureRecognizer*) recognizer {
    //one finger move
    if (recognizer.recognizerState == UIGestureRecognizerStateChanged && recognizer.maxFingerNum == 1) {  
        CGPoint v = [recognizer velocityInView:self.view]; //get the finger velocity
        CGPoint z = [recognizer translationInView:self.view]; // get the translation
        NSUInteger fingerNum = recognizer.maxFingerNum;  // get the finger number
        //Do other things you want to do...
    }

    if (recognizer.recognizerState == UIGestureRecognizerStateEnded) {  //recognized the gesture
        CGPoint v = [recognizer velocityInView:self.view]; //get the finger velocity
        CGPoint z = [recognizer translationInView:self.view]; // get the translation
        NSUInteger fingerNum = recognizer.maxFingerNum;  // get the finger number
        RYPanGesture gesture =  recognizer.gesture // get the recognized gesture
        //Do other things you want to do...
    }
}

Any bugs report is welcome!

Change Log

v0.1.0(2016-10-8)
First published version.

v0.1.1(2016-12-12)
Fix diagonal swipe recognizer and other bugs.

v0.2.0(2017-01-09)
Fix bugs when use with scrollView

v0.2.1(2017-02-10)
Fix bugs when use with other gestrue recognizer.

Latest podspec

{
    "name": "RYGestureRecognizer",
    "version": "0.2.1",
    "summary": "A gesture class to replace the system gesture.",
    "description": "This is a class to recognize gestures, which can recognize gestures like tap, swipe, pan, pinch, rotation, long press. You can use the class to replace the iOS sdk.n* 1. One gesture cycle begins with a touch in the screen and ends with all touches leave the screen. In one gesture recognize cycle, if there is a finger leaves the screen, but there are still fingers touches, and then another new touch occure, this gesture cycle will be considered a invaild gesture.n* 2. In action method, if you want to get the recognizer state(UIGestureRecognizerState), you should use the property of "recognizerState" rather than "state". The property of "state" in long press gesture action once is changed not ended. On other gestures the "state" is the same as "recognizerState".n* 3. In long press gesture, the action will called right after the long press gesture recognized once by default. and before all fingers leave the screen, the new gesture cycle will not begin. the recognizeState is UIGestureRecognizerStateEnded. If you want to still recognize the move action after the long press gesture, you should set the longPressActionOnce to NO. So the move action will still be recogized and action method will be called, but the recognizerState is changed. Also, the action method will be called at all finger leave the screen with the recognizeState to be ended.n* 4. In rotation and pan gesture, the action method will call when the touches move. the recognizeState is UIGestureRecognizerStateChanged.n* 5. The aciton method will not call at the begin of touch, if you wish, set the shouldDoActionAtTouchBegin with true.",
    "homepage": "https://github.com/Ekulelu/RYGestureRecognizer",
    "license": {
        "type": "Apache-2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Ekulelu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Ekulelu/RYGestureRecognizer.git",
        "tag": "0.2.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RYGestureRecognizer/*.{h,m}"
}

Pin It on Pinterest

Share This