Created
January 20, 2013 23:35
-
-
Save C4Code/4582585 to your computer and use it in GitHub Desktop.
Basic example for how to change a visible object's shadow path
This file contains hidden or 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 | |
// | |
// Created by Travis Kirton. | |
// | |
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *s, *c; | |
BOOL circleShadow; | |
} | |
-(void)setup { | |
c = [C4Shape ellipse:CGRectMake(0, 0, 100, 100)]; | |
s = [C4Shape rect:c.frame]; | |
s.center = self.canvas.center; | |
[self.canvas addShape:s]; | |
[self runMethod:@"newShadowPath" afterDelay:0.05f]; | |
[self runMethod:@"showPath" afterDelay:0.1f]; | |
} | |
-(void)newShadowPath { | |
if(circleShadow) { | |
s.shadowPath = c.shapeLayer.path; | |
circleShadow = NO; | |
} | |
else { | |
s.shadowPath = s.shapeLayer.path; | |
circleShadow = YES; | |
} | |
} | |
-(void)showPath { | |
s.animationDuration = 1.0f; | |
s.shadowOffset = CGSizeMake(20,20); | |
s.shadowOpacity = 0.8; | |
} | |
-(void)touchesBegan { | |
[self newShadowPath]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment