Best way to use UIGesture
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
NiceGesture.xcodeproj
NiceGesture
NiceGestureDemo
NiceGestureDemoUITests
.travis.yml
LICENSE
NiceGesture.podspec
README.md

README.md

NiceGesture

Build Status Language Carthage compatible CocoaPods License

The best way to use UIGesture

#Usage

###TapGesture:

because tapGesture is only have one state,so it's only have method whenTapped

  view.nc_addTapGestureWithConfigClosure { (tapGestureRecognizer) -> () in
            // Configure gesture recognizer,like this:
            tapGestureRecognizer.numberOfTapsRequired=2
        }.whenTapped {(tapGestureRecognizer) -> () in
            //doSomething()
        }
        
  // or you can directly do something 
  view.nc_whenTapped {(tapGestureRecognizer) -> () in
        //doSomething()
  }

###LongPress,Pan,Pinch,Rotate,Swipe,ScreenEdgesPan:

if you want to cinfigure gesture,use this method:

  view.nc_addxxxxGestureWithConfigClosure({ (gestureRecognizer) -> () in
        //Configure gesture recognizer
  })

if you needn't configure,use this method to start:

  view.nc_addxxxxGesture()

then,you can add hanlder function as you want:

   view.nc_addPanGesture()
       .whenBegan { (recognizer) -> Void in
            
       }.whenCancelled { (recognizer) -> Void in
            
       }.whenChanged { (recognizer) -> Void in
            
       }.whenEnded { (recognizer) -> Void in
            
       }.whenFailed { (recognizer) -> Void in
            
       }

a convenient way to use SwipeGesture:

   view.nc_whenSwipedInDirection(.Down) { (gestureRecognizer) in
            
        }

or if you want set one handler for many states,use whenStatesHappend:

lbState.nc_addPanGesture().whenStatesHappend([.Ended,.Changed]) { (gestureRecognizer) -> Void in
            
        }

###Attention

Custom gestureRecognizerHandler is retained by UIGestureRecognizer , UIGestureRecognizer is retained by target view, so if you're using self property remeber explicit [unowned self] to avoid retain cycle:

 lbState.nc_whenSwipedInDirection(.Down) {[unowned self]  (gestureRecognizer) in
            self.lbState.text="Down"
        }

#Installation

###CocoaPods To integrate NiceGesture into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'NiceGesture'

###Manual Just copy the files which under NiceGesture folder to your project

###Carthage github "lacklock/NiceGesture"

#Contact

Weibo : @没故事的卓同学

License

NiceGesture is available under the MIT license. See the LICENSE file for more info.