Created
June 7, 2012 00:50
-
-
Save C4Code/2885789 to your computer and use it in GitHub Desktop.
How to set and change layer positions of visible objects
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
#import "C4WorkSpace.h" | |
@implementation C4WorkSpace { | |
C4Shape *zPositionShape; | |
CGFloat zPosOfLastShape, offset; | |
NSInteger circleCount; | |
} | |
-(void)setup { | |
offset = 30; | |
circleCount = (NSInteger)(self.canvas.height/offset)+10; | |
for(int i = 0; i < circleCount; i++) { | |
CGFloat x, y, w, h; | |
w = 10 + (circleCount - i)*offset; | |
h = w; | |
x = 384 - w/2.0f; | |
y = 512 - h/2.0f; | |
if(i == 0) { | |
zPositionShape = [C4Shape ellipse:CGRectMake(x,y,w,h)]; | |
zPositionShape.userInteractionEnabled = NO; | |
zPositionShape.zPosition = i; | |
zPositionShape.lineWidth = 0.0f; | |
zPositionShape.fillColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8]; | |
[self.canvas addShape:zPositionShape]; | |
} else { | |
C4Shape *s = [C4Shape ellipse:CGRectMake(x,y,w,h)]; | |
s.zPosition = i; | |
s.fillColor = [C4GREY colorWithAlphaComponent:1.0/offset]; | |
s.lineWidth = 1.0f; | |
s.userInteractionEnabled = NO; | |
[self.canvas addShape:s]; | |
} | |
} | |
} | |
-(void)touchesBegan { | |
zPositionShape.animationDuration = 5.0f; | |
zPositionShape.animationOptions = AUTOREVERSE | REPEAT | LINEAR; | |
zPositionShape.zPosition = circleCount; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment