UIView动画全圆旋转与UIViewAnimationOptionCurveEaseInOut反转

use*_*706 1 animation uiview ios

           [UIView animateWithDuration:3 delay:0 options:( UIViewAnimationOptionCurveEaseInOut |
                                                       UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat |
                                                       UIViewAnimationOptionAllowUserInteraction) animations:^{
            self.animatedImageView.transform = CGAffineTransformRotate(self.animatedImageView.transform, M_PI);
        } completion:^(BOOL finished){}];
Run Code Online (Sandbox Code Playgroud)

这个动画怎么能是一个完整的圆周旋转,同时仍然加速和减速.如果我使用2*M_PI,则动画不会移动.

rde*_*mar 11

我认为这对你有用:

- (IBAction)rotate:(UIButton *)sender {

    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = @(M_PI * 2.0);
    rotationAnimation.duration = 1;
    rotationAnimation.autoreverses = YES;
    rotationAnimation.repeatCount = HUGE_VALF;
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.iv.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
Run Code Online (Sandbox Code Playgroud)


inc*_*iko 5

 [UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            self.animatedImageView.transform = CGAffineTransformRotate(self.animatedImageView.transform, M_PI);
        } completion:^(BOOL finished){

        [UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.animatedImageView.transform = CGAffineTransformRotate(self.animatedImageView.transform, (2*M_PI)-0.001); //  -0.001 will do the right way
    } completion:^(BOOL finished){}];


}];
Run Code Online (Sandbox Code Playgroud)