为什么CAAnimation Rotation返回到以前的状态 [英] Why CAAnimation Rotation is returning to previous state

查看:108
本文介绍了为什么CAAnimation Rotation返回到以前的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using CAKeyFrameAnimation to do rotation of an arrow image.

问题是动画后imageview返回到previos状态。

Problem is that the imageview is returning back to the previos state after animation.

代码:


CAKeyframeAnimation * rotation = [CAKeyframeAnimation animation];
rotation.duration = 0.55;
rotation.cumulative = TRUE;
rotation.removedOnCompletion =否;
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];

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];

} 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];

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

推荐答案

在调用addAnimation之前添加此行。.

Add this line before calling addAnimation..

rotation.fillMode = kCAFillModeForwards;

这篇关于为什么CAAnimation Rotation返回到以前的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆