函数代码:
#pragma mark彩色的圆
-(void)recordingCircleOverlayView
{
self.backgroundColor=[UIColorpurpleColor];
//根图层
CALayer*thelayer=[CALayerlayer];
thelayer.frame=CGRectMake(0,0,CGRectGetWidth(self.frame)/2.,CGRectGetWidth(self.frame)/2.);
thelayer.backgroundColor=[UIColorwhiteColor].CGColor;
[self.layeraddSublayer:thelayer];
//画圆
UIBezierPath*theCirclePath1=[UIBezierPathbezierPathWithArcCenter:CGPointMake(thelayer.position.x, thelayer.position.y)radius:90startAngle:M_PIendAngle:-M_PIclockwise:NO];
CAShapeLayer*theBigLayer=[CAShapeLayerlayer];
theBigLayer.path=theCirclePath1.CGPath;
theBigLayer.strokeColor=[UIColorpurpleColor].CGColor;
theBigLayer.fillColor=[UIColorclearColor].CGColor;
theBigLayer.lineWidth=5;
theBigLayer.strokeStart=0;
//分块颜色
CAGradientLayer*theGradien=[CAGradientLayerlayer];
theGradien.frame=thelayer.bounds;
theGradien.colors=@[
(__bridgeid)[UIColoryellowColor].CGColor,
(__bridgeid)[UIColorredColor].CGColor,
(__bridgeid)[UIColorblueColor].CGColor
];
theGradien.locations=@[@.25,@.5,@.8];
[thelayeraddSublayer:theGradien];
//遮罩
thelayer.mask=theBigLayer;
//动画
CABasicAnimation*baseAnim=[CABasicAnimationanimationWithKeyPath:@"strokeStart"];
baseAnim.fromValue=[NSNumbernumberWithFloat:0.];
baseAnim.toValue=[NSNumbernumberWithFloat:1.];
baseAnim.duration=5;
baseAnim.repeatCount=9;
[theBigLayeraddAnimation:baseAnimforKey:@"stro"];
}