如何嵌套多个CA动画?
如何像 UIView animateWithDuration 那样嵌套多个 CA 动画?例如,我需要制作 6 个动画,其中每个下一个动画都在前一个动画之后。因此,使用 UIView animateWithDuration,每个下一个动画都会从完整的块中调用。 CA是否允许使用块等?如果没有那么如何执行嵌套的顺序动画?
How to nest multiple CA animation like UIView animateWithDuration does? For example, I need to animate 6 animations where each next animation goes after previous one. So, with UIView animateWithDuration, every next animation is called from complete block. Does CA allows to use blocks and etc.? If no then how to perform nested sequential animations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CAAnimation
没有基于块的 API,但您可以使用其委托方法animationDidStop:finished:
来链接多个动画。如果您经常这样做,您可能需要为此编写自己的基于块的包装器。
CAAnimation
doesn't have a block-based API, but you could use its delegate methodanimationDidStop:finished:
to chain multiple animations.If you do this a lot, you may want to write your own block-based wrapper for this.
除了 omz 的答案之外,您还可以设置 NSTimer 对象来启动动画的连续部分。
其中legOne: 是执行动画第一部分等的方法。
Alternatively to omz's answer, you can set up NSTimer objects to start the successive parts of the animation.
Where legOne: is a method that does the first part of the animation, etc.