title: Efficient animation of time-variant drawing using CAKeyFrameAnimation
body: <p>My current goal is to animate the drawing of a picture in my iOS app so that a user could see something like <a href="http://www.youtube.com/watch?v=xlDmk5WdaHk" rel="nofollow noreferrer">http://www.youtube.com/watch?v=xlDmk5WdaHk</a> happening on their screen. </p>
  
  <p>The acceleration of my drawings vary with time so I've built my animation using <code>CAKeyFrameAnimation</code> and <code>keyTimes</code>. At the moment, I only have one Bezier path which specifies all the points of my drawing, I add the path to my <code>CAShapeLayer</code> object, and then pass the path off to my animation object when I start my animation. </p>
  
  <p><strong>My problem:</strong> the completed drawing immediately appears on the screen, and my pen cursor then moves along the picture according to my <code>keyTimes</code> values, instead of having the stroke color filling in tandem with my pen cursor movement on the screen to produce the same effect as the video.</p>
  
  <p>I noticed this SO question, where the recommended solution was to produce a separate path for every point in the animation: <a href="https://stackoverflow.com/questions/9762236/how-to-animate-coregraphics-drawing-of-shape-using-cakeyframeanimation">How to Animate CoreGraphics Drawing of Shape Using CAKeyframeAnimation</a></p>
  
  <p>Given that I have 100-300 individual points, is there a more efficient method of producing a time-variant drawing, than creating an array of a couple hundred paths (with a couple hundred values in each path) with the paths in this form:</p>
  
  <pre><code>path0 = point0...point0...point0...point0... 
  path1 = point0...point1...point1...point1...
  path2 = point0...point1...point2...point2...
  path3 = point0...point1...point2...point3...
  </code></pre>
  
  <p>Then taking that array of paths, passing it into <code>myAnimation.values</code> and animating <code>values</code>  with my <code>keyTimes</code>? Or is that really the best way to go about this?</p>
  
  <p>Thanks in advance</p>