objective-c – 核心动画动画

objective-c – 核心动画动画,第1张

概述这是在Core Animation上下文中链接动画的最优雅和模块化的方式吗? 我的意思是做动画,只是当其他完成(例如,改变位置,然后不透明度)开始..正常的方法是直接改变属性: layer.position = new_point;layer.opacity = 0.0f; 但这将同时做他们。我想让一个等待另一个。 和链接不同对象的动画怎么样?我已经阅读关于CATransaction使用像: [ 这是在Core Animation上下文中链接动画的最优雅和模块化的方式吗?

我的意思是做动画,只是当其他完成(例如,改变位置,然后不透明度)开始..正常的方法是直接改变属性:

layer.position = new_point;layer.opacity = 0.0f;

但这将同时做他们。我想让一个等待另一个。

和链接不同对象的动画怎么样?我已经阅读关于CATransaction使用像:

[CATransaction begin]layer1.property = new_property;[CATransaction begin]layer2.property2 = new_property2;[CATransaction commit];[CATransaction commit];

但它似乎不工作..

解决方法 您还可以使用动画分组并使用动画的beginTime字段。尝试这样:

CABasicAnimation *posAnimation = [CABasicAnimation animationWithKeyPath:@"position"];[posAnimation setFromValue:[NSNumber numberWithfloat:0.0]];[posAnimation setTovalue:[NSNumber numberWithfloat:1.0]];// Here's the important part[posAnimation setDuration:10.0];[posAnimation setBeginTime:0.0];CABasicAnimation *borderWIDthAnimation = [CABasicAnimation animationWithKeyPath:@"borderWIDth"];[borderWIDthAnimation setFromValue:[NSNumber numberWithfloat:0.0]];[borderWIDthAnimation setTovalue:[NSNumber numberWithfloat:1.0]];// Here's the important part[borderWIDthAnimation setDuration:10.0];[borderWIDthAnimation setBeginTime:5.0];CAAnimationGroup *group = [CAAnimationGroup animation];[group setDuration:10.0];[group setAnimations:[NSArray arrayWithObjects:posAnimation,borderWIDthAnimation,nil]];[layer addAnimation:group forKey:nil];

请注意,整个动画的持续时间为10秒。第一个从第二个0开始,第二个从5秒开始。

总结

以上是内存溢出为你收集整理的objective-c – 核心动画动画全部内容,希望文章能够帮你解决objective-c – 核心动画动画所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1044436.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存