title: How to animate contentsRect property along a path?
body: <p>I have a png sprite sheet and corresponding plist file loaded and I'm trying to animate contentsRect property of a CALayer to display a sprite animation from the above mentioned aprite sheet. Here is a code:</p>
  
  <pre><code>CGFloat width = myLayer.frame.size.width;
  CGFloat height = myLayer.frame.size.height;
  myLayer.bounds = CGRectMake( 0, 0, width, height );
  myLayer.contentsGravity = kCAGravityCenter;
  myLayer.contents=(id)pImage; // This is my sprite sheet
  
  
  CAKeyframeAnimation *keyFrameContentsRectAnimation = [CAKeyframeAnimation animationWithKeyPath:@"contentsRect"];
  keyFrameContentsRectAnimation.path = pAnimationPath; // This is a path to animate on
  keyFrameContentsRectAnimation.values = pRects; // This is an array of normalized CGRects representing sprite sheet
  keyFrameContentsRectAnimation.fillMode = kCAFillModeRemoved;
  keyFrameContentsRectAnimation.calculationMode = kCAAnimationDiscrete;
  keyFrameContentsRectAnimation.duration=pAnimationDuration;
  keyFrameContentsRectAnimation.repeatCount = 1;
  </code></pre>
  
  <p>The above code seems to be working as expected as long as I disable path animation (i.e. comment out path property from keyFrameContentsRectAnimation) - the animation works and contentsRect moves around my sprite sheet.</p>
  
  <p>But here is the problem: all my sprites require some offset within a layer frame in order to get my animation look right(offset varies depending on a transparency crop).</p>
  
  <p>So I figured if I create a path from these offset points that I have and get it into path property of my animation that should resolve the problem. Unfortunately it's not the case...
  As soon as I add path property, instead of sprites animation I see the whole sprite sheet image for the duration of animation... What did I miss?</p>