2010-10-09 25 views
0

我在我的應用程序下面的核心動畫代碼:iPhone核心動畫不能平滑運行?

-(void)startCoreAnimation 

    [UIView beginAnimations:@"IconFade" context:Icon]; 
    [UIView setAnimationCurve:UIViewAnimationCurveLinear]; 
    [UIView setAnimationDuration:1]; 

    [UIView setAnimationRepeatAutoreverses:YES]; 
    [UIView setAnimationDelegate:self]; 
    [UIView   setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; 

    icon.alpha=0.0; 
    [UIView commitAnimations]; 
    break; 

,然後在動畫完成:

-(void)animationFinished : (NSString *)theAnimation finished : (BOOL)flag context : (void *)context { 


((UIView *)context).alpha = 1.0; 
((UIView *)context).transform = CGAffineTransformIdentity; 

[self startCoreAnimation]; 

} 

的問題是,經過動畫完成圖標「跳」回它的alpha狀態爲1.它看起來像圖標淡入淡出,然後不利然後進入alpha 0,然後返回到alpha 1.在最後兩個步驟(alpha 0到alpha1)之間存在一個導致口吃的小間隙。誰能幫忙?

感謝,

馬丁

回答

0

如果你只是要循環的動畫,你也可以使用

[UIView setAnimationRepeatCount:1e100f];

根據documentation

設置repeatCount到1e100f將 導致動畫重複,直到從圖層中刪除 。