2012-08-13 56 views
0

我使用核心动画这样的尝试:创建一个常数纺纱的UIImageView

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear animations:^{ CGAffineTransform transform = CGAffineTransformMakeRotation(3.14); 
     self->inner.transform = transform; 
    } completion:NULL]; 
} 

这种旋转称为外我的UIImageView,但它并没有完成360度旋转后,即时消息顺利。它在3/4左右之后跳跃。我不应该在PI上轮换?

如果我想改变旋转方向,我该怎么做?它在一分钟内顺时针旋转。

感谢

+0

这是不是真的很好的做法。你应该使用自己的动画,没有'UIView'旋转你不断。 – Dustin 2012-08-13 16:14:10

+0

我应该使用石英还是类似的东西? – dev6546 2012-08-13 16:15:47

+0

你可以。或者,如果您没有动态内容,只需创建一个图像数组并使用'UIImageView'对象的'animationImages'。 – Dustin 2012-08-13 16:19:31

回答

7

如果任何人都需要这在任何一点:

//outer ring 
CABasicAnimation *fullRotationAnimation; 
fullRotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; 
fullRotationAnimation.fromValue = [NSNumber numberWithFloat:0.0f]; 
fullRotationAnimation.toValue = [NSNumber numberWithFloat:2 * M_PI]; 
fullRotationAnimation.duration = 4; 
fullRotationAnimation.repeatCount = 5000; 
//fullRotationAnimation.cumulative = YES; 
[self->outer.layer addAnimation:fullRotationAnimation forKey:@"360"];