CAAnimationGroup 与 CAKeyframeAnimation 的优缺点
我目前正在为 iOS 开发一些核心动画内容,并且非常享受。这个问题是关于实现动画的多种不同方式。假设您想要旋转 UIView 几次,但为每个动画周期使用不同的计时函数。据我所知,至少有两种不同的实现方法:
- 我创建一个 CAAnimationGroup 并向其中添加不同的 CABasicAnimation 对象。通过控制它们的beginTime属性并在它们上设置不同的CAMediaTimingFunction,我得到了我想要的个人行为。
- 另一个选项是创建一个 CAKeyframeAnimation 并通过添加不同的键值,我可以单独自定义不同的“框架”。
所以我的问题是:使用这些实现之一有什么优势吗?
我的后续问题:如果是这样,您使用什么方法来找出这个问题?换句话说,我将如何衡量动画的性能?
提前谢谢您并致以最诚挚的问候。
//Abeansits
I'm currently working on some core animation stuff for the iOS and really enjoying myself. This question is regarding the many different ways one can implement an animation. Say you would like to rotate a UIView a few times but with different timing functions for each animation cycle. To the best of my knowledge there are at least two different way of implementing this:
- I either create a
CAAnimationGroup
and add the differentCABasicAnimation
objects to it. By controlling theirbeginTime
property and setting differentCAMediaTimingFunction
on them I get the individual behavior I want. - The other option is to create a
CAKeyframeAnimation
and by adding different key values I can customize the different "frames" individually.
So my question is this: Is there any advantage of using either one of these implementations?
My follow up question: If so, what method do you use for finding this out? In other words, how would I go about measuring the performance of an animation?
Thank you in advance and best regards.
//Abeansits
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,两者之间的选择是一种语义选择:
To me, the choice between the two is a semantic one: