페이지

2017년 5월 15일 월요일

Subclass UIGestureRecognizer

#import <UIKit/UIKit.h>
#import <UIKit/UIGestureRecognizerSubclass.h> // required!!

@interface TouchGestureRecognizer : UIGestureRecognizer
@end


#import "TouchGestureRecognizer.h"
@implementation TouchGestureRecognizer
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    self.state = UIGestureRecognizerStateBegan;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesEnded:touches withEvent:event];
    self.state = UIGestureRecognizerStateEnded;
}

- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent *)event{
    [super touchesMoved:touches withEvent:event];
    self.state = UIGestureRecognizerStateChanged;
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesCancelled:touches withEvent:event];
    self.state = UIGestureRecognizerStateCancelled;
}


@end

댓글 없음:

댓글 쓰기