UIView 动画块与 CAAnimation
iOS动画专家!每种方法的优点和缺点是什么?我知道 Apple 建议使用块而不是旧的 UIView
动画方法(UIView
beginAnimations
等),但是 CAAnimation
又如何呢? >?您什么时候会使用一种方法而不是另一种方法?性能方面是否需要权衡?
iOS animation experts! What are the pros and cons of each method? I know Apple recommends blocks instead of the old UIView
animation methods (UIView
beginAnimations
, etc), but what about CAAnimation
? When would you use one method vs the other? Is there a tradeoff in terms of performance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1) UIView 的动画块和
CALayers
CAAnimation
之间的内存消耗以及对象本身没有太大差异。2) 使用
UIView
动画可以实现的动画类型存在限制,因此您可能不得不使用CAAnimation
。3) 对于 UIView 可以处理的那些类型的简单动画,它通常是比
CAAnimation
更简单的 API。1) There is not much difference in terms of memory expenses between UIView's animation blocks and
CALayers's
CAAnimation
nor in terms of the objects themselves.2) There are limitations to the type of animations you can achieve with
UIView's
animation, so you might be forced to useCAAnimation
anyway.3) For those types of simpler animations that UIView can handle, it is usually a simpler API to use than that of
CAAnimation
.正如 miamk 所说,使用 [UIView animateWith] 方法系列可以实现的动画类型存在限制。我个人使用 CAAnimation,但那是因为我习惯以这种方式设置动画。我觉得你有更多的控制权。我倾向于花一天时间对 CAAnimation 进行真正的微调,然后将其添加到我的 UIView 扩展类中,以便任何视图都可以使用它。
As miamk said, there are limitations to the types of animations you can achieve using the [UIView animateWith] method series. Personally I use CAAnimation, but that is because I am accustom to setting up animations that way. I feel you have more control. I tend to spend a day making a CAAnimation really really fine-tuned and then add it to my UIView extensions class so any view can use it.