Skip to content

Instantly share code, notes, and snippets.

@C4Tutorials
Last active December 16, 2015 10:49
Show Gist options
  • Save C4Tutorials/5423205 to your computer and use it in GitHub Desktop.
Save C4Tutorials/5423205 to your computer and use it in GitHub Desktop.
Pan Tutorial
//
// C4WorkSpace.m
// Pan Tutorial
//
// Created by Travis Kirton.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace {
C4Label *label;
}
-(void)setup {
[self setupLabel];
self.canvas.multipleTouchEnabled = YES;
[self addGesture:PAN name:@"pan" action:@"move:"];
}
-(void)move:(UIPanGestureRecognizer *)recognizer {
[label move:recognizer];
if(recognizer.state == UIGestureRecognizerStateBegan) {
NSInteger touchCount = recognizer.numberOfTouches;
label.text = [NSString stringWithFormat:@"%d Touch Pan", touchCount];
[label sizeToFit];
} else if (recognizer.state == UIGestureRecognizerStateEnded) {
label.animationDuration = 0.25f;
label.text = @"I'm a Drag";
[label sizeToFit];
label.center = self.canvas.center;
}
}
-(void)setupLabel {
C4Font *font = [C4Font fontWithName:@"AvenirNextCondensed-Heavy" size:96];
label = [C4Label labelWithText:@"I'm A Drag" font:font];
label.center = self.canvas.center;
label.userInteractionEnabled = NO;
[self.canvas addLabel:label];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment