Last active
December 14, 2015 19:39
-
-
Save gregtemp/5137980 to your computer and use it in GitHub Desktop.
Long pressed (how does it work?)
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
@implementation C4WorkSpace { | |
C4Shape *s1, *s2, *s3; | |
} | |
-(void)setup { | |
CGRect shapeFrame = CGRectMake(0, 0, 100, 100); | |
s1 = [C4Shape ellipse:shapeFrame]; | |
s2 = [C4Shape ellipse:shapeFrame]; | |
s3 = [C4Shape ellipse:shapeFrame]; | |
[self setupShapeGestures:s1]; | |
[self setupShapeGestures:s2]; | |
[self setupShapeGestures:s3]; | |
CGPoint centerPoint = self.canvas.center; | |
centerPoint.y -= 150; | |
s1.center = centerPoint; | |
centerPoint.y += 150; | |
s2.center = centerPoint; | |
centerPoint.y += 150; | |
s3.center = centerPoint; | |
NSArray *shapes = @[s1,s2,s3]; | |
[self.canvas addObjects:shapes]; | |
[self listenFor:@"pressedLong" fromObjects:shapes andRunMethod:@"randomColor:"]; | |
} | |
-(void)setupShapeGestures:(C4Shape *)shape{ | |
[shape addGesture:LONGPRESS name:@"longPress" action:@"pressedLong"]; | |
} | |
-(void)randomColor: (NSNotification *)notification { | |
C4Shape *shape = (C4Shape *)notification.object; | |
shape.fillColor = [UIColor colorWithRed:[C4Math randomInt:100]/100.0f | |
green:[C4Math randomInt:100]/100.0f | |
blue:[C4Math randomInt:100]/100.0f | |
alpha:1.0f]; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment