#pragma mark 绘制圆弧
- (void)drawArcForView:(UIView *)view {
//圆心
CGPoint circleCenterPoint = CGPointMake(CGRectGetWidth(view.frame)/2, CGRectGetHeight(view.frame)/2);
//半径
CGFloat radius = CGRectGetWidth(view.frame)/2;
//绘制圆
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:circleCenterPoint radius:radius startAngle:0 endAngle:M_PI*2 clockwise:YES];
CAShapeLayer *circleLayer = [CAShapeLayer layer];
circleLayer.lineWidth = 8;
circleLayer.strokeColor = [UIColor colorWithHex:0x333131].CGColor;
circleLayer.path = circlePath.CGPath;
circleLayer.fillColor = nil;
[view.layer addSublayer:circleLayer];
//绘制6段圆弧
//圆弧之间的间隔
double radianSpace = 20 / 180.0 / M_PI;
//每段圆弧弧度
double radian = M_PI * 2 / 6 - radianSpace;
//起点
double StarRadian = M_PI_2 + radianSpace / 2;
for (NSInteger i = 0; i < 6; i ++) {
UIBezierPath *arcPath = [UIBezierPath bezierPathWithArcCenter:circleCenterPoint radius:radius-2 startAngle:StarRadian endAngle:StarRadian + radian clockwise:YES];
CAShapeLayer *arcLayer = [CAShapeLayer layer];
arcLayer.lineWidth = 2;
if (i <= 2) {
arcLayer.strokeColor = [UIColor colorWithHex:0xff5f32].CGColor;
}else {
arcLayer.strokeColor = [UIColor colorWithHex:0x4b4b4b].CGColor;
}
arcLayer.path = arcPath.CGPath;
arcLayer.fillColor = nil;
[view.layer addSublayer:arcLayer];
StarRadian += M_PI * 2 / 6;
}
}
参考地址:http://www.cnblogs.com/jaesun/p/iOS-CAShapeLayerUIBezierPath-hua-xian.html