【问题标题】:how to stop CAKeyFrameAnimation in Iphone如何在 Iphone 中停止 CAKeyFrameAnimation
【发布时间】:2010-12-04 13:08:28
【问题描述】:

嗨,我目前正在使用简单的 amimation 应用程序,我在其中实现以下代码

CGMutablePathRef path = CGPathCreateMutable();
// CGPathMoveToPoint use to move position 
CGPathMoveToPoint(path, NULL, 160, 90);
//move image to state x Axes Right 
CGPathAddLineToPoint(path, NULL,-30, 90); 

animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path = path;
CFRelease(path);

animation.duration = 15.0;
animation.repeatCount = 0;
animation.rotationMode = kCAAnimationPaced;
animation.removedOnCompletion = YES;
[[ballImageView1 layer] addAnimation:animation forKey:@"zposition"];

但我的问题是,每当动画完成时,动画就会停止功能

【问题讨论】:

    标签: iphone iphone-sdk-3.0 core-animation


    【解决方案1】:

    我不确定你的问题。听起来您的动画停止了,而您要无限期地重复什么?

    通过设置repeatCount = 0,它只会遍历一次动画。

    你需要设置 repeatCount = HUGE_VALF 让它重复一遍。

    重复次数 确定动画将重复的次数。

    @property 浮点数重复计数 讨论 可能是分数。如果repeatCount 为0,则忽略它。默认为 0。如果同时指定了 repeatDuration 和 repeatCount,则行为未定义。

    将此属性设置为 HUGE_VALF 将导致动画永远重复。

    如果您只想让动画的最后一帧保持可见,请设置 removedOnCompletion = NO。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多