Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CAShapeLayer *shapeLayer=[CAShapeLayer layer];
- [shapeLayer setBounds:btn.frame];
- [shapeLayer setFillColor:[[UIColor blueColor] CGColor]];
- [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]];
- [shapeLayer setLineWidth:1.0f];
- UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:btn.frame cornerRadius:0.0];
- [shapeLayer setPath:path.CGPath];
- [[btn layer] addSublayer:shapeLayer];
- if ([shapeLayer animationForKey:@"linePhase"])
- [shapeLayer removeAnimationForKey:@"linePhase"];
- else {
- CABasicAnimation *dashAnimation;
- dashAnimation = [CABasicAnimation
- animationWithKeyPath:@"lineDashPhase"];
- [dashAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
- [dashAnimation setToValue:[NSNumber numberWithFloat:15.0f]];
- [dashAnimation setDuration:0.75f];
- [dashAnimation setRepeatCount:10000];
- [shapeLayer addAnimation:dashAnimation forKey:@"linePhase"];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement