I have the two CAShapeLayer
s forming the following display:
They are created with this piece of code:
CALayer *layer = [loadingView layer];
CAShapeLayer *circle = [CAShapeLayer layer];
[circle setPath:[[UIBezierPath bezierPathWithOvalInRect:CGRectMake(5, 5, loadingView.bounds.size.width - 10, loadingView.bounds.size.height - 10)] CGPath]];
[circle setStrokeColor:[UIColorFromRGB(0xffffff, .15) CGColor]];
[circle setLineWidth:5];
[circle setFillColor:[[UIColor clearColor] CGColor]];
[layer addSublayer:circle];
CAShapeLayer *arc = [CAShapeLayer layer];
[arc setPath:[[UIBezierPath bezierPathWithArcCenter:CGPointMake(27, 27) radius:22 startAngle:1.25*M_PI endAngle:1.75*M_PI clockwise:YES] CGPath]];
[arc setStrokeColor:[UIColorFromRGB(0xffffff, .8) CGColor]];
[arc setLineWidth:5];
[arc setFillColor:[[UIColor clearColor] CGColor]];
[layer addSublayer:arc];
I'd like for the smaller, opaque arc to retain its size and spin around the circle indefinitely. I've tried applying a number of transform.rotation
animations that I found on other answers, however the arc ends up spinning into unpredictable directions.
I've also tried raising strokeStart
and strokeEnd
of the arc at the same rate, which gets the effect I want at first but is unable to proceed cyclically due to the nature of those properties.
That being so, how to perform this effect?