如何做到的UIView不停翻转动画 [英] How to do UIView nonstop flip animation

查看:147
本文介绍了如何做到的UIView不停翻转动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得一个UIView做绕Y轴360度旋转不停的效果。

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

推荐答案

将下面的code在您的视图控制器:

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

这是pretty凌乱,如果任何人有关于如何清除这件事有任何建议,让我知道;)

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

这篇关于如何做到的UIView不停翻转动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆