Ios 使用核心动画淡出发射器单元

Ios 使用核心动画淡出发射器单元,ios,core-animation,caemitterlayer,caemittercell,Ios,Core Animation,Caemitterlayer,Caemittercell,我正在使用CAEmitterLayer和CAEmitterCell实例创建粒子动画。动画没有问题,但我希望它们慢慢淡出。我正在使用下面的代码,但是粒子突然消失,没有淡出动画 NSString *animationPath = [NSString stringWithFormat:@"emitterCells.%@.birthRate", cell.name]; CABasicAnimation *birthRateAnimation = [CABasicAnima

我正在使用CAEmitterLayer和CAEmitterCell实例创建粒子动画。动画没有问题,但我希望它们慢慢淡出。我正在使用下面的代码,但是粒子突然消失,没有淡出动画

        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"];
这段代码在for循环中为五个不同的发射器单元运行

你发现这段代码有错误吗


感谢CAEmitterCell将alpha speed值设置为-1.0/寿命。

嗨,洛迪,你有没有找到一种使发射极单元淡入淡出的方法?你知道如何使用它来淡入然后一次性淡出单元吗?