Как создать петлевую анимацию? - PullRequest
0 голосов
/ 27 июня 2018

Как создать петлевую анимацию? Я запускаю этот код и анимация выполняется 1 раз:

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
[animationGroup setDuration:0.4];
CABasicAnimation *firstAnimationLayer;
CABasicAnimation *secondAnimationLayer;
firstAnimationLayer = [CABasicAnimation animationWithKeyPath:@"startPoint"];
firstAnimationLayer.autoreverses = YES;
[firstAnimationLayer setRepeatCount:20];
[firstAnimationLayer setRepeatDuration:0.3];
[firstAnimationLayer setFromValue: [NSValue valueWithCGPoint:CGPointMake(0, 0)]];
[firstAnimationLayer setToValue: [NSValue valueWithCGPoint:CGPointMake(0.5, 0)]];
[firstAnimationLayer setDuration: 0.4];
[firstAnimationLayer setBeginTime:0.0];

secondAnimationLayer = [CABasicAnimation animationWithKeyPath:@"endPoint"];
secondAnimationLayer.autoreverses = YES;
[secondAnimationLayer setRepeatCount:20];
[secondAnimationLayer setRepeatDuration:0.3];
[secondAnimationLayer setFromValue: [NSValue valueWithCGPoint:CGPointMake(0.5, 0)]];
[secondAnimationLayer setToValue: [NSValue valueWithCGPoint:CGPointMake(0.5, 1)]];
[secondAnimationLayer setDuration: 0.4];
[secondAnimationLayer setBeginTime:0.0];
[animationGroup setAnimations:[NSArray arrayWithObjects:firstAnimationLayer, secondAnimationLayer, nil]];
[self.gradient addAnimation: animationGroup forKey:nil];

Я хочу создать анимацию для моего градиента и зациклить его.

1 Ответ

0 голосов
/ 27 июня 2018

Попробуйте это

[firstAnimationLayer setRepeatCount: INFINITY];
[secondAnimationLayer setRepeatCount: INFINITY];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...