YYGestureRecognizer.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // YYGestureRecognizer.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 14/10/26.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <UIKit/UIKit.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /// State of the gesture
  14. typedef NS_ENUM(NSUInteger, YYGestureRecognizerState) {
  15. YYGestureRecognizerStateBegan, ///< gesture start
  16. YYGestureRecognizerStateMoved, ///< gesture moved
  17. YYGestureRecognizerStateEnded, ///< gesture end
  18. YYGestureRecognizerStateCancelled, ///< gesture cancel
  19. };
  20. /**
  21. A simple UIGestureRecognizer subclass for receive touch events.
  22. */
  23. @interface YYGestureRecognizer : UIGestureRecognizer
  24. @property (nonatomic, readonly) CGPoint startPoint; ///< start point
  25. @property (nonatomic, readonly) CGPoint lastPoint; ///< last move point.
  26. @property (nonatomic, readonly) CGPoint currentPoint; ///< current move point.
  27. /// The action block invoked by every gesture event.
  28. @property (nullable, nonatomic, copy) void (^action)(YYGestureRecognizer *gesture, YYGestureRecognizerState state);
  29. /// Cancel the gesture for current touch.
  30. - (void)cancel;
  31. @end
  32. NS_ASSUME_NONNULL_END