首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CAKeyframeAnimation on CAEmitterCell颜色不工作

CAKeyframeAnimation on CAEmitterCell颜色不工作
EN

Stack Overflow用户
提问于 2016-12-03 13:18:23
回答 1查看 222关注 0票数 1

我尝试了所有的东西,但是我无法用CAEmitterCell的颜色属性与CAKeyframeAnimation动画。奇怪的是:我几乎可以把其他的东西都动画化(没有试过所有的东西,但似乎都是这样)。例如:动画包含backgroundColor的CAEmitterLayer的CAEmitterCell是没有问题的。此外,动画的CAEmitterCell规模工作很好。

下面是我代码的缩短版本:

代码语言:javascript
复制
let cell = CAEmitterCell()
...
cell.name = "main"
emitter.emitterCells = [cell]

let keyPath = "emitterCells.main.color"
// Uncomment this to see that the keyPath works correctly:
//emitter.setValue(UIColor(red: 1, green: 0, blue: 0, alpha: 1).cgColor, forKeyPath: keyPath)
...
let backColorPath = "backgroundColor"
// Use this to see that color animation is basically possible:
//let anim2 = CAKeyframeAnimation(keyPath: backColorPath)
let anim2 = CAKeyframeAnimation(keyPath: keyPath)
anim2.beginTime = CACurrentMediaTime()
anim2.duration = 5
anim2.keyTimes = [0, 0.25, 0.5, 0.75, 1]
anim2.repeatCount = 20
anim2.values = [UIColor.red.cgColor, UIColor.blue.cgColor,
            UIColor.yellow.cgColor, UIColor.cyan.cgColor,
            UIColor.magenta.cgColor]
emitter.add(anim2, forKey: "coloring")

有人知道我哪里出了问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-22 14:49:22

这是苹果图书馆里的一个bug,他们在iOS 11中修复了它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40948180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档