我正在使用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"];
答案 0 :(得分:1)
在调用addAnimation ..
之前添加此行rotation.fillMode = kCAFillModeForwards;