Combining animations into one property

How can I use two separate CABasicAnimations to create the same property at the same time?

For example, two CABasicAnimations, both are animated position.y.

The first animation will be a rebound (from 100 to 300, duration = 1, auto reverse = yes, repeat = 10)

The second animation will be slow scrolling (at 100, duration = 10)

The behavior that I see is that if the first animation is executed, and I use:

[pickle.layer addAnimation:[self makescrollanimation] forKey:@"scrollit"];

to add a second ... the second is ignored.

I know that the second animation works, because if I start from the second, then the first is ignored.

Thanks Matt

+3
source share
3

, , , . , , additive. :

CABasicAnimation *bounceAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
bounceAnimation.duration = 1;
bounceAnimation.fromValue = [NSNumber numberWithInt:100];
bounceAnimation.toValue = [NSNumber numberWithInt:300];
bounceAnimation.repeatCount = 10;
bounceAnimation.autoreverses = YES;
bounceAnimation.fillMode = kCAFillModeForwards;
bounceAnimation.removedOnCompletion = NO;
bounceAnimation.additive = YES;
[view.layer addAnimation:bounceAnimation forKey:@"bounceAnimation"];

CABasicAnimation *scrollAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
scrollAnimation.duration = 10;
scrollAnimation.fromValue = [NSNumber numberWithInt:0];
scrollAnimation.toValue = [NSNumber numberWithInt:100];
scrollAnimation.fillMode = kCAFillModeForwards;
scrollAnimation.removedOnCompletion = NO;
scrollAnimation.additive = YES;
[view.layer addAnimation:scrollAnimation forKey:@"scrollAnimation"];

, . .

+5

,

, , , NSZeroPoint, NSZeroRect . .

+1

CAAnimationGroup, , , , CABasicAnimations. .

, , - UIView scrollit , .

, !

0

Source: https://habr.com/ru/post/1703307/


All Articles