iPhone核心动画运行不顺畅?

时间:2010-10-09 20:15:04

标签: iphone objective-c uikit core-animation

我的应用程序中有以下核心动画代码:

-(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)有一个小间隙导致口吃。有人可以帮忙吗?

谢谢,

马丁

1 个答案:

答案 0 :(得分:0)

如果您只想循环播放动画,也可以使用

[UIView setAnimationRepeatCount:1e100f];

根据documentation

  

将repeatCount设置为1e100f将   导致动画重复直到它   从图层中移除。