Походные муравьи с основной анимацией вокруг круга - PullRequest
0 голосов
/ 29 марта 2019

Я устанавливаю анимацию марширующих муравьев по кругу. Как я могу установить анимацию для округлой формы.

Я уже сделал анимацию пунктирной линией, но только вокруг прямоугольника.

CAShapeLayer *shapeLayer = [CAShapeLayer layer];
[shapeLayer setPath:[[UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 50, 100, 100)] CGPath]];
CGRect shapeRect = CGRectMake(0.0f, 0.0f, 100.0f, 100.0f);

[shapeLayer setPosition:CGPointMake(240.0f, 140.0f)];
[shapeLayer setFillColor:[[UIColor yellowColor] CGColor]];
[shapeLayer setStrokeColor:[[UIColor redColor] CGColor]];
[shapeLayer setLineWidth:2.0f];
[shapeLayer setLineJoin:kCALineJoinRound];
[shapeLayer setLineDashPattern:
 [NSArray arrayWithObjects:[NSNumber numberWithInt:10],
  [NSNumber numberWithInt:5],
  nil]];

CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, shapeRect);

[shapeLayer setPath:path];
CGPathRelease(path);

[[[self view] layer] addSublayer:shapeLayer];

CABasicAnimation *dashAnimation;
dashAnimation = [CABasicAnimation animationWithKeyPath:@"lineDashPhase"];

[dashAnimation setFromValue:[NSNumber numberWithFloat:0.0f]];
[dashAnimation setToValue:[NSNumber numberWithFloat:15.0f]];
[dashAnimation setDuration:0.75f];
[dashAnimation setRepeatCount:INFINITY];

[shapeLayer addAnimation:dashAnimation forKey:@"linePhase"];

Я ожидаю, что вокруг слоя фигуры будет анимированная пунктирная линия.

...