旋转轮不显示缓和效果和缓和效果

时间:2016-08-15 09:34:22

标签: ios animation

我使用了以下代码来旋转26段的轮子。问题是它没有显示easeIn和easy out的效果。

- (void) spinWithOptions: (UIViewAnimationOptions) options {
   // this spin completes 360 degrees every 2 seconds
   [UIView animateWithDuration: 0.5f
                         delay: 0.0f
                       options: options
                    animations: ^{
                       self.imageToMove.transform = CGAffineTransformRotate(imageToMove.transform, M_PI_2/6.49);
                    }
                    completion: ^(BOOL finished) {
                       if (finished) {
                          if (animating) {
                             // if flag still set, keep spinning with constant speed
                             [self spinWithOptions: UIViewAnimationOptionCurveLinear];
                          } else if (options != UIViewAnimationOptionCurveEaseOut) {
                             // one last spin, with deceleration
                             [self spinWithOptions: UIViewAnimationOptionCurveEaseOut];
                          }
                       }
                    }];
}

- (void) startSpin {
   if (!animating) {
      animating = YES;
      [self spinWithOptions: UIViewAnimationOptionCurveEaseIn];
   }   
}

- (void) stopSpin {
    // set the flag to stop spinning after one last 90 degree increment
    animating = NO;
}

1 个答案:

答案 0 :(得分:0)

EaseIn导致动画缓慢开始然后加速,这应该仅在第一个0.5秒的动画上发生,然后你使用UIViewAnimationOptionCurveLinear并且仅用于你使用的最后一个动画{{1 }}

据我所知,代码看起来没问题,您确定可以在如此短的时间内看到EastOut效果吗?尝试设置更长的持续时间,看看是否会发生效果。

相关问题