4

I need to synchronize a path animation on two different layers (one is used as a mask for another layer, the other shows a graphical element that follows the path, i.e. draws the mask). If I just set them up identically, they never quite do the same thing. Currently, I am using a CAKeyframeAnimation with a path (for the graphical element) and a CABasicAnimation, where I animate "strokeEnd" of the same path from 0.0 to 1.0 (for the mask).

I guess an animation group does not work here, since that would mean I apply the group to the mask layer, which would hide the graphical element.

Joseph Tura
  • 6,290
  • 8
  • 47
  • 73

2 Answers2

5

Have you set calculationMode = kCAAnimationPaced for the keyframe animation?

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256
  • Nope, I had not. That actually did fix my problem. Thanks, Ole. Somehow you seem to have all the animation related answers :) – Joseph Tura Dec 12 '10 at 09:38
  • Glad I could help. I am working on a similar task at the moment so we likely hit the same stumbling blocks. – Ole Begemann Dec 12 '10 at 11:27
  • 1
    My app does this as well using an path defined by 'bezierPathWithOvalInRect:' and I've noticed that in iOS 7 the graphical element following the path is no longer synchronized with the `strokeEnd` of the basic animation. Have you run into this? Any ideas how to fix? – XJones Oct 08 '13 at 19:01
2

Apple has informed me of a known bug in iOS7 where certain paths (such as elliptical paths) will not work well with respect to animating 2 different layers along the same path, e.g. strokeEnd of one layer, and position of another layer. Specifically, the 2 animations fall in and out of sync during the animation, and look sloppy. Apple also informed me there is no known workaround. I also filed a bug with Apple.

user2860400
  • 251
  • 2
  • 5