Stop CABasicAnimation after deletion after completion

Hi, I have this piece of code (duration is .5, quantity 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 it plays, the UIView grows correctly, but then returns to its original value. I thought "removedOnCompletion" should have prevented this?

+5
source share
1 answer

Looks like I also needed to specify:

  grow.fillMode = kCAFillModeForwards;

Move the shape. It works now :)

+16
source

All Articles