用贝舍尔曲线绘制分段闭合圆环
-(void)createCircleWithCount:(CGFloat)count num:(CGFloat)num { if(count <= 0 || num < 0 || num > count) { return; } else if(num == count || 0 == num) { CAShapeLayer *layer = [CAShapeLayer new]; layer.lineWidth = 7.5; //圆环的颜色 if(0 == num) { layer.strokeColor = [UIColor whiteColor].CGColor; } else { layer.strokeColor = BGColorHex(FFC67B).CGColor; } //背景填充色 layer.fillColor = [UIColor clearColor].CGColor; //设置半径为10 CGFloat radius = 49; //按照顺时针方向 BOOL clockWise = NO; //初始化一个路径 UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(FULL_WIDTH - COMMON_EDGE_DISTANCE -49, (FULL_WIDTH*222.5/375*3/4-98 -28.5)/2 +49) radius:radius startAngle:0 endAngle:2*M_PI clockwise:clockWise]; layer.path = [path CGPath]; [self.evaluatingReportBackgroundHeadView.layer addSublayer:layer]; return; } CGFloat endAngle = num/count; if(endAngle <= 0.5) { endAngle = M_PI - endAngle *M_PI*2; } else { endAngle = M_PI + (1 - endAngle) *2*M_PI; } CAShapeLayer *layer = [CAShapeLayer new]; layer.lineWidth = 7.5; //圆环的颜色 layer.strokeColor = BGColorHex(FFC67B).CGColor; //背景填充色 layer.fillColor = [UIColor clearColor].CGColor; //设置半径为10 CGFloat radius = 49; //按照顺时针方向 BOOL clockWise = NO; //初始化一个路径 UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(FULL_WIDTH - COMMON_EDGE_DISTANCE -49, (FULL_WIDTH*222.5/375*3/4-98 -28.5)/2 +49) radius:radius startAngle:(1*M_PI) endAngle:endAngle clockwise:clockWise]; layer.path = [path CGPath]; [self.evaluatingReportBackgroundHeadView.layer addSublayer:layer]; layer = [CAShapeLayer new]; layer.lineWidth = 7.5; //圆环的颜色 layer.strokeColor = [UIColor whiteColor].CGColor; //背景填充色 layer.fillColor = [UIColor clearColor].CGColor; //设置半径为10 radius = 49; //按照顺时针方向 clockWise = YES; //初始化一个路径 path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(FULL_WIDTH - COMMON_EDGE_DISTANCE -49, (FULL_WIDTH*222.5/375*3/4-98 -28.5)/2 +49) radius:radius startAngle:(1*M_PI) endAngle:endAngle clockwise:clockWise]; layer.path = [path CGPath]; [self.evaluatingReportBackgroundHeadView.layer addSublayer:layer]; }