如何对两个CABasicAnimation动画进行分组并在完全相同的时间将它们启动? [英] How to group two CABasicAnimation animations and kick them off at the exact same time?

查看:92
本文介绍了如何对两个CABasicAnimation动画进行分组并在完全相同的时间将它们启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道核心动画中存在某种动画分组机制。所以可以说我有两个CABasicAnimation firstAnimation secondAnimation 。我将如何对它们进行分组以及如何开始进行动画处理?

I know there is some kind of animation grouping mechanism in core animation. So lets say I have two CABasicAnimation firstAnimation and secondAnimation. How would I group these and how would I kick off the group to start animating?

推荐答案

您将要使用CAAnimationGroup类。创建一个包含所需动画的数组,然后将AnimationGroup的动画属性设置为该数组。 CAAnimationGroup是CAAnimation的子类,因此您可以像常规动画一样使用 [layer addAnimation:forKey:] 将其添加到图层中。添加到图层后,组中的所有动画将同时执行。

You'll want to use the CAAnimationGroup class. Create an array containing the animations you want, and set the AnimationGroup's animations property to that array. CAAnimationGroup is a subclass of CAAnimation, so you can add it to a layer using [layer addAnimation:forKey:] like you would a regular animation. Once added to a layer, all animations in a group execute concurrently.

我建议阅读 CAAnimationGroup参考首先。在使用之前,有许多实现细节值得理解。例如:

I would suggest reading the CAAnimationGroup Reference first. There are a number of implementation details worth understanding before you use it. For example:


  1. 单个动画的 delegate 属性将被忽略。

  2. 单个动画的 removeOnCompletion 属性将被忽略。

  3. AnimationGroup具有自己的委托 removeOnCompletion 属性。

  4. 动画没有按时间缩放到该组,因此如果单个动画的持续时间长于组对象的持续时间,则会在组的持续时间结束时中断。

  5. 动画属性。

  1. The delegate property of individual animations is ignored.
  2. The removeOnCompletion property of individual animations is ignored.
  3. The AnimationGroup has its own delegate and removeOnCompletion properties.
  4. Animations aren't time-scaled to the group, so if an individual animation has a duration longer than that of the group object, it will be interrupted at the end of the group's duration.
  5. The animations property of CAAnimationGroup is copied, not retained.

这篇关于如何对两个CABasicAnimation动画进行分组并在完全相同的时间将它们启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆