Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, you can definitely change the speed of an animation. That's because <code>CAKeyframeAnimation</code> confirms to the protocol <code>CAMediaTiming</code>.</p> <p>Apple explains this in their <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Animation_Types_Timing/Introduction/Introduction.html#//apple_ref/doc/uid/TP40006668-SW1" rel="nofollow noreferrer">Animation Types and Timing Programming Guide</a>.</p> <p>Have a look at the section on <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Animation_Types_Timing/Articles/Timing.html#//apple_ref/doc/uid/TP40006670-SW1" rel="nofollow noreferrer">Timing, Timespaces, and CAAnimation</a>.</p> <p>Specifically:</p> <blockquote> <p>"The speed property of an animation or layer specifies this scaling factor. For example, a 10 second animation that is attached to a layer with a timespace that has a speed value of 2 will take 5 seconds to display (twice the speed). If a sublayer of that layer also defines a speed factor of 2, then its animations will display in 1/4 the time (the speed of the superlayer * the speed of the sublayer)."</p> </blockquote> <p>Could I also point you in the direction of some excellent videos that cover this? Have a look at:</p> <p><a href="https://developer.apple.com/videos/wwdc/2010/" rel="nofollow noreferrer">WWDC 2010 Sessions 424 and 425 Core Animation in Practice Parts 1 and 2</a></p> <p><a href="https://developer.apple.com/videos/wwdc/2011/" rel="nofollow noreferrer">WWDC 2011 Session 421 Core Animation Essentials</a></p> <p>and </p> <p><a href="https://developer.apple.com/videos/iphone/" rel="nofollow noreferrer">Developer Videos Session 716 Core Animation Techniques for iPhone and Mac</a></p> <p>You can even change the speed of an animation to effectively "freeze" it. It's very useful for pausing and resuming. Although one caveat is that it won't behave properly if the app is backgrounded, or purged from memory. That you'll have to deal with manually. </p> <p>See the <a href="http://developer.apple.com/library/ios/#qa/qa1673/_index.html#//apple_ref/doc/uid/DTS40010053" rel="nofollow noreferrer">Technical Q&amp;A QA1673</a>, and my answer to this question for more info on that process:</p> <p><a href="https://stackoverflow.com/questions/5919025/is-there-an-issue-with-updating-a-calayer-position-while-the-layer-is-paused/7984067#7984067">Is there an issue with updating a CALayer position while the layer is paused?</a></p>
 

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