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

查看:16
本文介绍了为什么 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 动画];旋转时间 = 0.55;旋转.累积 = TRUE;旋转.removedOnCompletion = NO;如果(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];

}别的 {rotation.values = [NSArray arrayWithObjects:[NSValue 值WithCATransform3D: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天全站免登陆