Skip to content

Instantly share code, notes, and snippets.

@daoseng33
Created July 26, 2018 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daoseng33/65aa908db1df882eb63fff9496f7c12f to your computer and use it in GitHub Desktop.
Save daoseng33/65aa908db1df882eb63fff9496f7c12f to your computer and use it in GitHub Desktop.
// Set up the shape of the circle
CAShapeLayer *border = [CAShapeLayer layer];
border.path = [UIBezierPath bezierPathWithRoundedRect:self.myImageView.frame cornerRadius:self.myImageView.frame.size.height/2].CGPath;
border.anchorPoint = CGPointMake(0.5, 0.5);
border.position= CGPointMake(self.myImageView.bounds.origin.x, self.myImageView.bounds.origin.y);
border.fillColor = [UIColor clearColor].CGColor;
border.strokeColor = [UIColor blueColor].CGColor;
border.lineWidth = 5; [self.view.layer addSublayer:border];
// Configure animation
// draw Border
CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.delegate = self;
drawAnimation.duration = 7.0;
drawAnimation.repeatCount = 1.0;
[drawAnimation setValue:border forKey:@"afterBorderLoading"];
drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];
drawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[border addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment