本文介绍了NSView动画后删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么它是如此困难,但是基本上我想在整个屏幕上制作一个NSView动画,一旦完成该动画,就删除该NSView.但是,似乎我找不到有关如何执行此操作的参考.有人可以帮忙吗?

I do not know why it is proving to be so difficult, but basically I want to animate an NSView across my screen, and once it is done that animation, remove that NSView. It however seems that I can find absolutely no reference on how to do this. Can someone please help?

我要像这样开始动画

NSRect frame = blob.frame;
frame.origin.x = animationStopX;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:timeToDisappear];
[[blob animator] setFrame:frame];
[NSAnimationContext endGrouping];

一旦完成,我将无法从中获得回调.

I have no way of getting a callback from this once it completes or anything.

推荐答案

beginGrouping语句之后,添加以下内容:

Right after your beginGrouping statement, add this:

[[NSAnimationContext currentContext] setCompletionHandler:^{
        [self.blob removeFromSuperview];
    }];

setCompletionHandler:NSAnimationContext类中的方法.

这篇关于NSView动画后删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-20 23:36