NSView动画后删除

MZi*_*an6 1 macos xcode objective-c nsview

我不知道为什么它被证明是如此困难,但基本上我想在我的屏幕上动画一个NSView,一旦完成那个动画,就删除那个NSView.然而,似乎我完全没有找到关于如何做到这一点的参考.有人可以帮忙吗?

我正在开始这样的动画

NSRect frame = blob.frame;
frame.origin.x = animationStopX;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:timeToDisappear];
[[blob animator] setFrame:frame];
[NSAnimationContext endGrouping];
Run Code Online (Sandbox Code Playgroud)

一旦完成或任何事情,我无法从此获得回调.

rde*_*mar 7

在您的beginGrouping声明之后,添加以下内容:

[[NSAnimationContext currentContext] setCompletionHandler:^{
        [self.blob removeFromSuperview];
    }];
Run Code Online (Sandbox Code Playgroud)

setCompletionHandler:NSAnimationContext班上的一种方法.