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

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

4

3 回答 3

10

我认为这应该适合你:

- (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"];
}
于 2013-09-17T15:51:16.430 回答
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){}];


}];
于 2013-09-17T12:13:20.137 回答
1

这应该有效。您可以更改动画类型:UIViewAnimationTransitionFlipFromRight

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:(UIViewAnimationTransitionFlipFromRight)
                       forView:Your_View cache:YES];
[UIView commitAnimations];
于 2015-08-24T07:52:45.333 回答