self.circleVictor.backgroundColor = [UIColor greenColor];
CAShapeLayer *circle = [self LayerWithCircleCenter:CGPointMake(self.circleVictor.center.x, self.circleVictor.center.y)
radius:self.circleVictor.width/2
startAngle:radians(0)
endAngle:radians(360)
clockwise:YES
fillColor:UICOLOR_ARGB(0xffe0e0e0)
lineDashPattern:nil];
circle.strokeColor = [UIColor redColor].CGColor;
[self.circleVictor.layer addSublayer:circle];
// circle.strokeEnd = 1.f;
// colorLayer.mask = circle;
}
(CAShapeLayer *)LayerWithCircleCenter:(CGPoint)point
radius:(CGFloat)radius
startAngle:(CGFloat)startAngle
endAngle:(CGFloat)endAngle
clockwise:(BOOL)clockwise
fillColor:(UIColor*)fillColor
lineDashPattern:(NSArray *)lineDashPattern
{
CAShapeLayer *layer = [CAShapeLayer layer];// 贝塞尔曲线(创建一个圆)
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:point
radius:radius
startAngle:startAngle
endAngle:endAngle
clockwise:clockwise];// 获取path
layer.path = path.CGPath;
layer.position = point;// 设置填充颜色为透明
layer.fillColor = fillColor.CGColor;// 获取曲线分段的方式
if (lineDashPattern)
{
layer.lineDashPattern = lineDashPattern;
}return layer;
}(void)drawCircleLine: (CALayer )layer withlineWidth: (CGFloat)width withLineColor: (UIColor )lineColor withFillColor: (UIColor *)fillColor withFrame :(CGRect)frame
{
CAShapeLayer *solidLine = [CAShapeLayer layer];
CGMutablePathRef solidPath = CGPathCreateMutable();
solidLine.lineWidth = width ;
solidLine.strokeColor = lineColor.CGColor;
solidLine.fillColor = fillColor.CGColor;
CGPathAddEllipseInRect(solidPath, nil, frame);
solidLine.path = solidPath;
CGPathRelease(solidPath);
[layer addSublayer:solidLine];
}(void)drawArcLine: (CALayer )layer withlineWidth: (CGFloat)width withLineColor: (UIColor )lineColor withFillColor: (UIColor *)fillColor withFrame :(CGRect)frame
{
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
//设置画笔颜色:黑色
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
//设置画笔线条粗细
CGContextSetLineWidth(context, 0.6);//扇形参数
double radius=40;//半径
int startX=50;//圆心x坐标
int startY=50;//圆心y坐标
double pieStart=0;//起始的角度
double pieCapacity=60;//角度增量值
int clockwise=0;//0=逆时针,1=顺时针//逆时针画扇形
CGContextMoveToPoint(context, startX, startY);
CGContextAddArc(context, startX, startY, radius, radians(pieStart), radians(pieStart+pieCapacity), clockwise);
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathEOFillStroke);
}