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

问题描述 投票:0回答:1

我使用下面的代码来旋转26段的轮子。问题是它没有显示缓和和缓出的效果。

- (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;
}
ios animation
1个回答
0
投票

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

据我所知,代码看起来还不错,你确定你能在如此短的时间内看到EaseIn效果吗?尝试设置更长的持续时间,看看是否会发生效果。

© www.soinside.com 2019 - 2024. All rights reserved.