self.layer = [CAShapeLayer layer]; self.layer.frame = CGRectMake(0, 0, 100, 100); self.layer.position = self.view.center; self.layer.lineWidth = 10.0; self.layer.fillColor = [UIColor clearColor].CGColor; self.layer.strokeColor = [UIColor lightGrayColor].CGColor; self.layer.lineCap = kCALineCapSquare; /* CA_EXTERN NSString *const kCALineCapButt __OSX_AVAILABLE_STARTING (__MAC_10_6, __IPHONE_3_0); CA_EXTERN NSString *const kCALineCapRound __OSX_AVAILABLE_STARTING (__MAC_10_6, __IPHONE_3_0); CA_EXTERN NSString *const kCALineCapSquare */ UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)]; self.layer.path = path.CGPath; [self.view.layer addSublayer:self.layer]; self.layer.strokeEnd = 0.0; _progress = 0; self.timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES]; //更新下载进度 _progress += 0.01; if (self.layer.strokeEnd >= 1) { self.timer.fireDate = [NSDate distantFuture]; } else { self.layer.strokeEnd = _progress; }
时间: 2024-11-03 00:33:38