2010-10-09 63 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将 导致动画重复,直到从图层中删除 。