【问题标题】:Fading out emitter cells with Core Animation使用 Core Animation 淡出发射器单元
【发布时间】:2014-06-16 13:37:20
【问题描述】:

我正在使用 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 循环中针对五个不同的发射器单元运行。

您发现此代码中有错误吗?

谢谢

【问题讨论】:

  • 嗨 Élodie,你找到淡出发射器单元的方法了吗?

标签: ios core-animation caemitterlayer caemittercell


【解决方案1】:

对于 CAEmitterCell,将 alpha 速度值设置为 -1.0/lifetime。

【讨论】:

  • 知道如何使用它来淡入然后一次性淡出单元格吗?
猜你喜欢
  • 1970-01-01
  • 2017-06-13
  • 2010-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-20
  • 2011-07-12
  • 1970-01-01
相关资源
最近更新 更多