Élo*_*tit 8 core-animation ios caemitterlayer caemittercell
我正在使用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"];
Run Code Online (Sandbox Code Playgroud)
该代码在for循环中运行,用于五个不同的发射器单元.
你在这段代码中发现了错误吗?
谢谢
| 归档时间: |
|
| 查看次数: |
1491 次 |
| 最近记录: |