I am creating particle animations with instances of CAEmitterLayer and CAEmitterCell. There is no problem with the animation, but I want them to slowly disappear. I use the following code, but the particles suddenly disappear, and the animation does not disappear there.
NSString *animationPath = [NSString stringWithFormat:@"emitterCells.%@.birthRate", cell.name]; CABasicAnimation *birthRateAnimation = [CABasicAnimation animationWithKeyPath:animationPath]; birthRateAnimation.fromValue = [NSNumber numberWithFloat:30.0]; birthRateAnimation.toValue = [NSNumber numberWithFloat:0.0]; birthRateAnimation.removedOnCompletion = NO; birthRateAnimation.duration = 10.0; [emitterLayer addAnimation:birthRateAnimation forKey:@"birthRate"];
This code runs in a for loop for five different emitter cells.
Did you notice an error in this code?
thanks
ios core-animation caemitterlayer caemittercell
Γlodie Petit
source share