如何以CABasicAnimation为动画进行回调? [英] How can I callback as a CABasicAnimation is animating?
问题描述
我有一个动画我用来将可旋转的UIView捕捉到圆形网格。随着视图的动画效果,我需要根据旋转视图位置更新另一个视图。
I have an animation I'm using to snap a rotatable UIView to a circular grid. As the view animates, I need to update another view based on the rotating views position.
如何将旋转视图的位置设为它动画到位?
How can I go about getting the position of the rotating view as it animates into position?
推荐答案
当动画开始时你可以启动一个函数,它将使用一个轮询当前视图位置计时器(我想你需要从视图层获取 presentationLayer
并从中获取位置值)。
When animation starts you can start a function that will be polling current view position using a timer (I suppose you will need to get presentationLayer
from view's layer and get position values from it).
除了 animationDidStart
和 animationDidStop
所以这似乎是解决方案(如果我没有弄错的话,也会在WWDC视频中提到它。)
There's no callbacks for CAAnimation other than animationDidStart
and animationDidStop
so it seems that's the solution (if I'm not mistaken it was also mentioned so in one of WWDC videos).
这篇关于如何以CABasicAnimation为动画进行回调?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!