How to do UIView nonstop flip animation

泄露秘密 提交于 2019-12-24 20:07:20

问题


I want to get an effect of a UIView doing 360 degree rotation around the Y axis without stopping.


回答1:


Put the following code in your view controller:

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;
                                      }];
                 }];

It's pretty messy, if anybody has any suggestions on how to clear this up, let me know ;)



来源:https://stackoverflow.com/questions/8041662/how-to-do-uiview-nonstop-flip-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!