Skip to content

Instantly share code, notes, and snippets.

@armandocanals
Last active August 29, 2015 14:00
Show Gist options
  • Save armandocanals/7238f46db38a8ed290e8 to your computer and use it in GitHub Desktop.
Save armandocanals/7238f46db38a8ed290e8 to your computer and use it in GitHub Desktop.
- (void) drawCountdownSpinner {
int radius = 70;
CAShapeLayer *circle = [CAShapeLayer layer];
circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius)
cornerRadius:radius].CGPath;
circle.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
CGRectGetMidY(self.view.frame)-radius-40);
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor whiteColor].CGColor;
circle.lineWidth = 5;
[_countdownView.layer addSublayer:circle];
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration = 15.0;
drawAnimation.repeatCount = 1.0;
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment