Skip to content

Instantly share code, notes, and snippets.

@arielelkin
Created November 14, 2012 17:45
Show Gist options
  • Save arielelkin/4073608 to your computer and use it in GitHub Desktop.
Save arielelkin/4073608 to your computer and use it in GitHub Desktop.
Animating Slice of Donut
float radius = 300;
CAShapeLayer *donut = [CAShapeLayer layer];
donut.bounds = CGRectMake(0,0,radius, radius);
donut.cornerRadius = radius/2;
donut.borderWidth = 2;
donut.borderColor = [UIColor redColor].CGColor;
[self.layer addSublayer:donut];
CAShapeLayer *progressiveDonut = [CAShapeLayer layer];
progressiveDonut.bounds = donut.bounds;
progressiveDonut.path = donut.path;
progressiveDonut.cornerRadius = donut.cornerRadius;
progressiveDonut.backgroundColor = nil;
progressiveDonut.strokeColor = [UIColor orangeColor].CGColor;
progressiveDonut.lineWidth = 4;
progressiveDonut.strokeStart = 0.0;
progressiveDonut.strokeEnd = 0.3;
progressiveDonut.lineJoin = kCALineJoinBevel;
progressiveDonut.borderWidth = 3;
progressiveDonut.borderColor = [UIColor blueColor].CGColor;
[self.layer addSublayer:progressiveDonut];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment