我想按一個按鈕時將圖像轉動190度。這有效,但是當我再次按下按鈕時,動畫需要從最後結束的地方開始,而不是從0開始。所以,每次按下按鈕,動畫都需要變成190度。Xcode圖像旋轉toValue和from價值
它從0開始,每次becouse我fromValue設置爲0
是否有人知道我可以讓fromValue地方開始我的形象結束。我的代碼在這裏。
- (IBAction)buttonPressed
{
CABasicAnimation *imageRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
imageRotation.fromValue = [NSNumber numberWithFloat:0];
imageRotation.toValue = [NSNumber numberWithFloat:((190*M_PI)/ -180)];
imageRotation.duration = 1.5;
imageRotation.repeatCount = 1;
imageRotation.removedOnCompletion = NO;
imageRotation.autoreverses=NO;
imageRotation.fillMode = kCAFillModeForwards;
[image.layer addAnimation:imageRotation forKey:@"imageRotation"];
}