Created
April 19, 2013 21:26
-
-
Save C4Tutorials/5423345 to your computer and use it in GitHub Desktop.
Advanced Pan Tutorial
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
// | |
// C4WorkSpace.m | |
// Pan Tutorial | |
// | |
// Created by Travis Kirton. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *circle; | |
} | |
-(void)setup { | |
circle = [C4Shape ellipse:CGRectMake(0, 0, 386, 386)]; | |
circle.userInteractionEnabled = NO; | |
circle.center = self.canvas.center; | |
[self.canvas addShape:circle]; | |
[self addGesture:PAN name:@"pan" action:@"modifyLineWidth:"]; | |
} | |
-(void)modifyLineWidth:(UIPanGestureRecognizer *)recognizer { | |
CGPoint translation = [recognizer translationInView:self.canvas]; | |
[recognizer setTranslation:CGPointZero inView:self.canvas]; | |
CGFloat lineWidth = [C4Math absf:translation.x] + [C4Math absf:translation.y]; | |
circle.lineWidth = [C4Math constrainf:lineWidth min:5 max:150]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment