有没有办法弄清楚,在动画中当前旋转视图的度数? [英] Is there a way to figure out, how many degrees an view is rotated currently during an animation?
问题描述
我正在使用此变换在动画块中应用旋转变换动画:
I am applying an rotation transform animation in an animation block with this transform:
CATransform3D rotatedTransform = self.layer.transform;
rotatedTransform = CATransform3DRotate(rotatedTransform, 90 * M_PI / 180.0, 0.0f, 0.0f, 1.0f);
self.layer.transform = rotatedTransform;
动画开始,用户开始另一个必须将轮换推向新的事件目标。为了计算逼真的行为,我需要知道旋转的当前程度是什么,以便可以适当地加上下一个旋转度。
The animation begins, and the user kicks in another event that would have to push the rotation towards a new target. To calculate realistic looking behavior, I need to know what's the current degrees of the rotation, so that the next rotation degrees can be added up appropriately.
推荐答案
这是一个老问题,但我在尝试在关键帧动画中找到当前旋转角度时遇到了这个答案: -
This is an old question but I came across this answer while trying to find the current rotation angle during a key frame animation:-
CALayer* layer = [self.layer presentationLayer];
float currentAngle = [[layer valueForKeyPath:@"transform.rotation.z"] floatValue];
似乎对我有用。此外,简洁明了。
Seems to work for me. Also, nice and concise.
这篇关于有没有办法弄清楚,在动画中当前旋转视图的度数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!