0
A
回答
4
-(void)startAnimationWithRevolutions:(float)revPerSecond forTime:(float)time
{
spinWheel.userInteractionEnabled = FALSE;
float totalRevolutions = revPerSecond * time;
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:time] forKey:kCATransactionAnimationDuration];
CABasicAnimation* spinAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation"];
CGAffineTransform transform = spinWheel.transform;
float fromAngle = atan2(transform.b, transform.a);
float toAngle = fromAngle + (totalRevolutions*4*M_PI);
spinAnimation.fromValue = [NSNumber numberWithFloat:fromAngle];
spinAnimation.toValue = [NSNumber numberWithFloat:toAngle];
spinAnimation.repeatCount = 0;
spinAnimation.removedOnCompletion = NO;
spinAnimation.delegate = self;
spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseOut];
[spinWheel.layer addAnimation:spinAnimation forKey:@"spinAnimation"];
[CATransaction commit];
}
嘗試使用這一點,它的工作原理。
0
你卡在哪一部分? – 2011-05-21 06:32:15
我需要創造「財富之輪」。我有圓形圖像,但我不知道如何旋轉它。你能幫忙嗎? – meetpd 2011-05-21 06:34:58
你知道如何顯示圖像嗎?你知道如何以一個角度展示它嗎?你知道如何設置一個計時器來定期改變角度嗎?重申:你堅持哪部分?如果你證明你已經做出了一些努力來自己解決問題,那麼在stackoverflow上獲得幫助通常會更容易。 – 2011-05-21 06:38:32