获取当前的CAAnimation变换值 [英] Get current CAAnimation transform value
问题描述
我想访问在某个时间点获取变换比例的值.这是动画创作:
I want to access get the value of the transform scale at a point in time. Here is the animation creation :
CABasicAnimation *grow = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
grow.toValue = @1.5f;
grow.duration = 1;
grow.autoreverses = YES;
grow.repeatCount = HUGE_VALF;
[view.layer addAnimation:grow forKey:@"growAnimation"];
例如,当用户按下按钮时,我想获取视图的当前大小. 记录框架或边界始终返回常数值.任何帮助将不胜感激!
I'd like to get, for example when a user presses a button, the current size of the view. Logging the frame or the bounds always returns constant values. Any help would be much appreciated !
推荐答案
CALayer文档非常清楚地描述了presentationLayer
:
The CALayer documentation describes presentationLayer
quite clearly:
此方法返回的图层对象提供了当前在屏幕上显示的图层的近似值.在动画制作过程中,您可以检索该对象并使用它获取这些动画的当前值.
The layer object returned by this method provides a close approximation of the layer that is currently being displayed onscreen. While an animation is in progress, you can retrieve this object and use it to get the current values for those animations.
这篇关于获取当前的CAAnimation变换值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!