ボタンを押したときに画像を190度回転させたいとします。それはうまくいきますが、ボタンをもう一度押すと、0から始まるのではなく、最後に終了した場所からアニメーションを開始する必要があります。ボタンを押すたびにアニメーションを190度回転させる必要があります。Xcode画像の回転toValueおよびfromValue
それは私の場合、fromValue becouse 0たびに開始されたが、誰かが私は私のイメージはどこで終了場合、fromValueを開始させることができる方法を知っています0
に設定されています。私のコードはここにあります。
- (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"];
}