2010-12-04 185 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。