当 CABasicAnimation 制作动画时如何回调?
我有一个动画,用于将可旋转的 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当动画开始时,您可以启动一个函数,该函数将使用计时器轮询当前视图位置(我想您需要从视图层获取presentationLayer并从中获取位置值)。
除了
animationDidStart
和animationDidStop
之外,CAAnimation 没有回调,所以这似乎是解决方案(如果我没记错的话,在 WWDC 视频之一中也提到过)。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).There's no callbacks for CAAnimation other than
animationDidStart
andanimationDidStop
so it seems that's the solution (if I'm not mistaken it was also mentioned so in one of WWDC videos).