AnimationDidStop 方法的多个 CAAnimations?
我知道您必须使用此方法来获取动画完成时的委托方法:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
问题是,我如何区分多个 CAAnimations(例如 2 个或更多)?
我用谷歌搜索了这个,但没有发现任何有用的东西。
请与我分享您是如何实现这一目标的!
谢谢!
I know you have to use this method to get the delegate method for when the animation has finished:
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
The problem is, how would I distinguish between multiple CAAnimations like 2 or more?
I googled this and I haven't found anything useful.
Please share with me on how you accomplished this!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以为 CAAnimation 实例设置键/值对象,如下所示:
检查委托方法中调用了哪一个:
You can set key/value objects for CAAnimation instance like this:
Check which one was called in delegate method:
CAAnimation 对象应该不时地被重用,这就是为什么我不喜欢给它一个特定的键(因为它不是唯一的)。它的独特之处在于与 CALayer 和
addAnimation:forKey:
的关联。因此,我在animationDidStop
中使用以下代码:A
CAAnimation
object is supposed to be reused from time to time and that's why I don't like to give it a certain key (since it's not unique). What makes it unique is the association with a CALayer withaddAnimation:forKey:
. For this reason I use the following code inanimationDidStop
: