cocoa – 核心动画……循环动画?

cocoa – 核心动画……循环动画?,第1张

概述要尽可能简单地说出我的问题,有没有办法创建一个核心动画序列来反复重复直到停止? 具体来说,我正在创建一个自定义类,我希望有一个-start和-stop方法,它会使它产生脉动.为脉冲编写动画代码不是问题,而是如何使其重复? 提前感谢您的任何答案! 根据 the documentation,你可以通过创建一个极大的repeatCount动画来实现它(代码摘自我链接到的文档): // create th 要尽可能简单地说出我的问题,有没有办法创建一个核心动画序列来反复重复直到停止?

具体来说,我正在创建一个自定义类,我希望有一个-start和-stop方法,它会使它产生脉动.为脉冲编写动画代码不是问题,而是如何使其重复?

提前感谢您的任何答案!

解决方法 根据 the documentation,你可以通过创建一个极大的repeatCount动画来实现它(代码摘自我链接到的文档):
// create the animation that will handle the pulsing.CABasicAnimation* pulseAnimation = [CABasicAnimation animation];// over a one second duration,and run an infinite// number of timespulseAnimation.duration = 1.0;pulseAnimation.repeatCount = HUGE_VALF;// we want it to fade on,and fade off,so it needs to// automatically autoreverse.. this causes the intensity// input to go from 0 to 1 to 0pulseAnimation.autoreverses = YES;

编辑:OP询问如何停止动画.从文档中的next paragraph开始:

You start an explicit animation by
sending a addAnimation:forKey: message
to the target layer,passing the
animation and an IDentifIEr as
parameters. Once added to the target
layer the explicit animation will run
until the animation completes,or it
is removed from the layer. The
IDentifIEr used to add an animation to
a layer is also used to stop it by
invoking removeAnimationForKey:. You
can stop all animations for a layer by
sending the layer a
removeAllAnimations message.

总结

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

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

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

原文地址:https://54852.com/web/1102439.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存