Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>CAAnimationGroup</code> is meant for having multiple <code>CAAnimation</code> subclasses being stacked together to form an animation, for instance, one animation can perform an scale, the other moves it around, while a third one can rotate it, it's not meant for managing multiple layers, but for having multiple overlaying animations.</p> <p>That said, I think the easiest way to solve your issue, is to assign each <code>CAAnimation</code> a <code>beginTime</code> equivalent to the sum of the durations of all the previous ones, to illustrate:</p> <pre><code>for i in 0 ..&lt; 20 { let view : UIView = // Obtain/create the view...; let bounce = CAKeyframeAnimation(keyPath: "transform.scale") bounce.duration = 0.5; bounce.beginTime = CACurrentMediaTime() + bounce.duration * CFTimeInterval(i); // ... view.layer.addAnimation(bounce, forKey:"anim.bounce") } </code></pre> <p>Notice that everyone gets <code>duration * i</code>, and the <code>CACurrentMediaTime()</code> is a necessity when using the <code>beginTime</code> property (it's basically a high-precision timestamp for "now", used in animations). The whole line could be interpreted as <code>now + duration * i</code>.</p> <p>Must be noted, that if a <code>CAAnimation</code>s is added to a <code>CAAnimationGroup</code>, then its <code>beginTime</code> becomes relative to the group's begin time, so a value of <code>5.0</code> on an animation, would be <code>5.0</code> seconds after the whole group starts. In this case, you don't use the CACurrentMediaTime()</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload