标签:
第一种加载方法
- (void)drawRect:(CGRect)rect { UIBezierPath *backPath = [UIBezierPath bezierPath]; [backPath moveToPoint:CGPointMake(0, 0)]; [backPath addLineToPoint:CGPointMake(0, rect.size.height)]; [backPath addLineToPoint:CGPointMake(rect.size.width, rect.size.height)]; [backPath addLineToPoint:CGPointMake(rect.size.width, 0)]; [backPath closePath]; [self.superview.backgroundColor set]; [backPath fill]; CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect)); CGFloat lineW = 3 / [UIScreen mainScreen].scale; UIBezierPath *backProPath = [UIBezierPath bezierPath]; [backProPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI * 2 clockwise:true]; backProPath.lineWidth = lineW; [[UIColor grayColor] set]; [backProPath stroke]; UIBezierPath *progressPath = [UIBezierPath bezierPath]; [progressPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI_4 clockwise:true]; progressPath.lineWidth = lineW; [[UIColor redColor] set]; [progressPath stroke]; }
第二种加载方法
- (void)drawRect:(CGRect)rect { UIBezierPath *tempPath = [UIBezierPath bezierPathWithRect:rect]; [self.superview.backgroundColor set]; [tempPath fill]; CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect)); CAShapeLayer *backLayer = [CAShapeLayer layer]; backLayer.lineWidth = 3 / [UIScreen mainScreen].scale; backLayer.strokeColor = [UIColor cyanColor].CGColor; backLayer.fillColor = [UIColor redColor].CGColor; [self.layer addSublayer:backLayer]; UIBezierPath *backPath = [UIBezierPath bezierPath]; [backPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 3 startAngle:0 endAngle:M_PI_4 clockwise:true]; backLayer.path = backPath.CGPath; }
标签:
原文地址:http://www.cnblogs.com/shenhongbang/p/4776667.html