【问题标题】:iPhone Core Animation not Running Smoothly?iPhone Core Animation 运行不流畅?
【发布时间】:2010-10-09 20:15:03
【问题描述】:

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

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

谢谢,

马丁

【问题讨论】:

    标签: iphone objective-c uikit core-animation


    【解决方案1】:

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

    [UIView setAnimationRepeatCount:1e100f];

    根据documentation

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-23
      • 1970-01-01
      • 2015-04-24
      • 1970-01-01
      相关资源
      最近更新 更多