Stop CABasicAnimation from being removed after completion
Asked Answered
A

1

6

Hey, I have this code snippet (duration is .5, amount is 1.5)

CABasicAnimation *grow = [CABasicAnimation animationWithKeyPath:@"transform"];
grow.duration = duration;
grow.repeatCount = 0;
grow.removedOnCompletion = NO;
grow.autoreverses = NO;
grow.fromValue = [NSValue valueWithCATransform3D:CATransform3DScale(self.layer.transform, 1.0, 1.0, 1.0)];
grow.toValue = [NSValue valueWithCATransform3D:CATransform3DScale(self.layer.transform, amount, amount, amount)];
grow.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[self.layer addAnimation:grow forKey:@"grow"];

However when this is played, the UIView grows properly, but then snaps back to its starting value. I thought the "removedOnCompletion" was supposed to prevent this?

Alfreda answered 15/3, 2011 at 22:48 Comment(0)
A
23

Looks like I also needed to specify:

  grow.fillMode = kCAFillModeForwards;

Go figure. Works now :)

Alfreda answered 15/3, 2011 at 23:0 Comment(1)
Nice line! exactly what I needed!Passionate

© 2022 - 2024 — McMap. All rights reserved.