Circle loader animation and circle loader Animation
Circle loader animation by Wu xueying
Github code
-(Void) awakeFromNib {[selfsetup];
[Self startAnimation];
}
-(Void) setup {
Self. backgroundColor = [UIColorclearColor];
Self. backgroundLayer = [CAShapeLayerlayer];
_ BackgroundLayer. strokeColor = [UIColorcolorWithRed: 0.129 green: 0.455 blue: 0.627 alpha: 1.0]. CGColor;
_ BackgroundLayer. fillColor = self. backgroundColor. CGColor;
_ BackgroundLayer. lineCap = kCALineCapRound;
_ BackgroundLayer. lineWidth = 1;
[Self. layeraddSublayer: _ backgroundLayer];
}
-(Void) startAnimation {
CGFloat startAngle =-(float) M_PI/2 );
CGFloat endAngle = (1.8f * (float) M_PI) + startAngle;
UIBezierPath * processBackgroundPath = [UIBezierPathbezierPath];
ProcessBackgroundPath. lineWidth = 1;
[ProcessBackgroundPath addArcWithCenter: CGPointMake (self. bounds. size. width/2, self. bounds. size. height/2)
Radius :( self. bounds. size. width-1)/2
StartAngle: startAngle
EndAngle: endAngle
Clockwise: YES];
_ BackgroundLayer. path = procw.ackgroundpath. CGPath;
CABasicAnimation * rotationAnimation = [CABasicAnimationanimationWithKeyPath: @ "transform. rotation. z"];
RotationAnimation. toValue = [NSNumbernumberWithFloat: M_PI * 2.0];
RotationAnimation. duration = 1;
RotationAnimation. cumulative = YES;
RotationAnimation. repeatCount = HUGE_VALF;
[_ BackgroundLayeraddAnimation: rotationAnimationforKey: @ "rotationAnimation"];
}
-(Void) drawRect :( CGRect) rect {
_ BackgroundLayer. frame = self. bounds ;}