如何做UIView不间断翻转动画

时间:2011-11-07 19:45:17

标签: iphone objective-c animation uiview flip

我希望UIView能够在不停止的情况下围绕Y轴进行360度旋转。

1 个答案:

答案 0 :(得分:1)

将以下代码放在视图控制器中:

CATransform3D t3d = CATransform3DIdentity;
// m34 sets the amount of perspective
t3d.m34 = 1.0/-1000.0;

[UIView animateWithDuration:1.0 
                      delay:0.0 
                    options:UIViewAnimationCurveLinear 
                 animations:^{
                     self.view.layer.transform = CATransform3DRotate(t3d, M_PI, 0, 1, 0);
                 } 
                 completion:^(BOOL finished) {
                     [UIView animateWithDuration:1.0 
                                           delay:0.0 
                                         options:UIViewAnimationCurveLinear 
                                      animations:^{
                                          self.view.layer.transform = CATransform3DRotate(t3d, 2*M_PI, 0, 1, 0);
                                      } 
                                      completion:^(BOOL finished) {
                                          self.view.layer.transform = CATransform3DIdentity;
                                      }];
                 }];

如果有人对如何清除这一点有任何建议,那就太乱了,请告诉我;)