iPhone:同步两个不同图层上的动画
我需要同步两个不同图层上的路径动画(一个用作另一图层的蒙版,另一个显示遵循路径的图形元素,即绘制蒙版)。如果我只是将它们设置为相同,它们永远不会做完全相同的事情。目前,我使用带有路径(对于图形元素)的 CAKeyframeAnimation 和 CABasicAnimation,其中我将同一路径的“行程结束”从 0.0 动画到 1.0(对于蒙版)。
我想动画组在这里不起作用,因为这意味着我将组应用到遮罩层,这将隐藏图形元素。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否为关键帧动画设置了calculationMode = kCAAnimationPaced?
Have you set
calculationMode = kCAAnimationPaced
for the keyframe animation?Apple 通知我 iOS7 中的一个已知错误,其中某些路径(例如椭圆路径)对于沿同一路径对 2 个不同层进行动画处理(例如,一层的描边结束和另一层的位置)无法正常工作。具体来说,两个动画在动画播放过程中时而同步,时而不同步,看起来很草率。苹果还告诉我没有已知的解决方法。我还向 Apple 提交了一个错误。
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.