2010-12-04 202 views
1

喜亚姆简单amimation应用工作中,我执行下面的代码如何在iPhone停止CAKeyFrameAnimation目前

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"]; 

但我的问题是,每当动画完成,然后anmation停止FUNC

回答

0

我不确定你的问题。这听起来像你的动画停止,你无限期重复什么?

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

您需要设置repeatCount = HUGE_VALF才能让它重复播放。

repeatCount 决定动画重复的次数。

@property float repeatCount 讨论 可能是小数。如果repeatCount为0,则忽略。默认为0.如果指定了repeatDuration和repeatCount,则行为未定义。

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

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