为什么CAAnimation Rotation返回到先前的状态

时间:2010-05-14 08:25:48

标签: rotation calayer cakeyframeanimation

我正在使用CAKeyFrameAnimation来旋转箭头图像。

问题是在动画之后,imageview将返回到previos状态。

代码:

CAKeyframeAnimation *rotation = [CAKeyframeAnimation animation]; rotation.duration = 0.55; rotation.cumulative = TRUE; rotation.removedOnCompletion = NO; if (isFlipRight) { rotation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0.0f, 1.0f, 0.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f)],nil];

} else { rotation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0f, 1.0f, 0.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0.0, 0.0f, 1.0f, 0.0f)],nil];

}

[[arrowImageView layer] addAnimation:rotation forKey:@"transform"];

1 个答案:

答案 0 :(得分:1)

在调用addAnimation ..

之前添加此行
rotation.fillMode = kCAFillModeForwards;