Created
April 14, 2015 17:24
-
-
Save kocyigityunus/0af6dbe65344a33e7c73 to your computer and use it in GitHub Desktop.
async display kit -- AsControlNode states
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "PRImageNode.h" | |
#import <AsyncDisplayKit/ASControlNode+Subclasses.h> | |
@interface PRImageNode(){ | |
// PRImageNode class is derived from ASImageNode which derived from ASControlNode | |
BOOL _touched; | |
} | |
@end | |
@implementation PRImageNode | |
-(id)init{ | |
if( !( self = [super init] ) ) | |
return nil; | |
return self; | |
} | |
-(void) makeTouched{ | |
self.borderWidth = 5; | |
self.borderColor = [UIColor blackColor].CGColor; | |
self.cornerRadius = 3; | |
} | |
-(void) cancelTouched{ | |
self.borderWidth = 0; | |
self.cornerRadius = 0; | |
} | |
-(BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)touchEvent{ | |
_touched = true; | |
[self makeTouched]; | |
return YES; | |
} | |
-(BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)touchEvent{ | |
CGPoint touchLocation = [touch locationInView:self.view]; | |
if( CGRectContainsPoint(self.bounds, touchLocation) ){ | |
if( !_touched ){ | |
_touched = true; | |
[self makeTouched]; | |
} | |
}else{ | |
[self cancelTrackingWithEvent:touchEvent]; | |
_touched = false; | |
[self cancelTouched]; | |
} | |
return YES; | |
} | |
-(void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)touchEvent{ | |
_touched = false; | |
[self cancelTouched]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment