1漆魔、圓形進(jìn)度條
?效果圖:
函數(shù)代碼:
直接添加到 view.layer ?直接調(diào)用方法就可以坷檩。
/**
*? 畫圓進(jìn)度條
*/
-(void)drawCircle
{
CAShapeLayer *circleLayer=[CAShapeLayer layer];
//設(shè)置位置
circleLayer.lineWidth=2.0;
circleLayer.fillColor=[UIColor whiteColor].CGColor;
//線的顏色
circleLayer.strokeColor=[UIColor redColor].CGColor;
//路徑
UIBezierPath *path=[UIBezierPath bezierPath];//bezierPathWithOvalInRect:CGRectMake(self.frame.size.width/4, self.frame.size.height/2, 200, 200)];
[path addArcWithCenter:CGPointMake(self.frame.size.width/2., self.frame.size.height/2.) radius:100 startAngle:0 endAngle:2*M_PI clockwise:YES];
circleLayer.path=path.CGPath;
[self.layer addSublayer:circleLayer];
circleLayer.strokeStart=0.0;
circleLayer.strokeEnd=.9;
CABasicAnimation *pathAnima=[CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnima.duration=3;
pathAnima.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
pathAnima.fromValue=[NSNumber numberWithFloat:0.];
pathAnima.toValue=[NSNumber numberWithFloat:1.];
pathAnima.fillMode=kCAFillModeForwards;
pathAnima.removedOnCompletion=NO;
[circleLayer addAnimation:pathAnima forKey:@"path"];
//? ? dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//
//? ? ? ? [UIView animateWithDuration:20 animations:^{
//? ? ? ? ? ? circleLayer.strokeEnd=1;
//? ? ? ? }];
//
//? ? });
}