按顺序组合多个 CAAnimation
我正在阅读有关 CATransactions 的内容,然后认为这可能有助于解决我的问题。
这就是我不想做的: 我在同一层中有 3 个动画,它们都有自己的持续时间。我使用 CAKeyframeAnimation 和 CGMutablePathRef 创建动画。
例如:
- anim1 ->持续时间 5 秒的
- 动画2 -> 3s
- 动画3 -> 10s
现在我想按顺序序列化它们。我尝试使用 CAAnimationGroup 但动画同时运行。 我读到了 CATransaction,这是一个可能的解决方案吗?你能给我举个小例子吗?
感谢您的帮助!
I was reading about CATransactions and then thought this might help solve my problem.
This is what I wan't to do:
I have 3 animations in the same layer, which all have their own duration. I create the animations using CAKeyframeAnimation with a CGMutablePathRef.
say for example:
- anim1 -> duration 5s
- anim2 -> 3s
- anim3 -> 10s
Now I want to serialize them sequentially. I tried to use CAAnimationGroup but the animations run concurrently.
I read about CATransaction, is it a possible solution? Can you give me a little example?
thanks for help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果序列化是指在前一个动画完成后开始每个动画,请使用
beginTime
属性(在CAMediaTiming
协议中定义)。请注意,它的文档有点误导。这是一个例子:If by serialization you mean starting each animation after the previous one has finished, use the
beginTime
property (defined inCAMediaTiming
protocol). Note that its documentation is a little misleading. Here's an example:如果您确定使用图层执行此操作,那么您可以尝试按照
在 CATransactions 中使用完成块
另一种方法是通过应用延迟来开始动画。
如果您将使用 UIVIew 动画
}
If You are sure to do this thing with Layers then you may try like following
Using Completion Block in CATransactions
Another way is by applying delay to begin animation.
And if You are going to use UIVIew Animation
}