我想创建一个CALayer动画,给出一种“浮华”效果。为此,我试图给“不透明”属性设置动画,但我的问题是我不知道从哪里开始以及如何去做。CALayer不透明度动画
这里是动画的图形说明:
opacity
| ___
1 | | |
| | | * repeatCount
0 |___| |_ . . .
-------------------------> time
|______|
duration
的不透明度开始于0,则动画为1,然后至0再次(这个0到1到0的动画需要数秒数等于持续时间)。然后这个过程重复'repeatCount'次。
下面是对代码的一些背景:
float duration = ...; // 0.2 secs, 1 sec, 3 secs, etc
int repeactCount = ...; // 1, 2, 5, 6, ect
CALayer* layer = ...; // I have a CALayer from another part of the code
layer.opacity = 0;
// Animation here
done = YES; // IN THE END of the animation set this ivar to yes
什么是实现这一目标的最佳方式是什么?我以前从未使用CALayers,因此这也是了解他们的动画系统如何工作的好机会。顺便说一下,我搜索了文档,并且我理解你如何添加一个或两个简单的动画,但我不知道如何做这个特定的动画。
upvote for the graph XD –