2012-08-13 57 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"];