Created
July 26, 2018 05:16
-
-
Save daoseng33/65aa908db1df882eb63fff9496f7c12f to your computer and use it in GitHub Desktop.
This file contains 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
// 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