0
我有一個電話輪。在發言中,它以動畫的形式出現在他的位置上。用CGAffineTransformIdentity逆時針轉爲順時針方向
直到角度小於180°,它會順時針返回。沒問題,用此代碼:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [UIView setAnimationBeginsFromCurrentState:YES]; [UIView beginAnimations:nil context:NULL]; [UIViewsetAnimationDuration:0.5]; wheel.transform = CGAffineTransformIdentity; [UIView commitAnimations]; }
但它出錯後繼續旋轉完成轉。
我試圖做出動畫像這樣:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [UIView setAnimationBeginsFromCurrentState:YES]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.2]; wheel.transform = CGAffineTransformRotate(wheel.transform, degreesToRadians(-130)); [UIView commitAnimations]; [self performSelector:@selector(animatewheelViewToCenter) withObject:nil afterDelay:0.3]; } - (void)animatewheelViewToCenter{ [UIView setAnimationBeginsFromCurrentState:YES]; [UIView beginAnimations:nil context:NULL]; [UIViewsetAnimationDuration:0.3]; wheel.transform = CGAffineTransformIdentity; [UIView commitAnimations]; }
它的工作原理,但動畫不是流體;該變化是可見的。
這是正確的,操作系統爲此執行操作的方式是錯誤的,動畫將最短路徑旋轉回縮進,這就是爲什麼您將問題解決的問題 – Daniel 2009-08-04 23:44:51