ボタンを押したときに画像を190度回転させたい。それは機能しますが、もう一度ボタンを押すと、アニメーションは 0 からではなく、最後に終了した場所から開始する必要があります。したがって、ボタンを押すたびに、アニメーションは 190 度回転する必要があります。
fromValue が 0 に設定されているため、毎回 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"];
}