我想按一个按钮时将图像转动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"];
}