[英]NSView Remove after animation
我不知道为什么它是如此困难,但是基本上我想在整个屏幕上制作一个NSView动画,一旦完成该动画,就删除该NSView。 但是,似乎我找不到有关如何执行此操作的参考。 有人可以帮忙吗?
我正在开始这样的动画
NSRect frame = blob.frame;
frame.origin.x = animationStopX;
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:timeToDisappear];
[[blob animator] setFrame:frame];
[NSAnimationContext endGrouping];
一旦完成,我无法从中获得回调。
在beginGrouping
语句之后,添加以下内容:
[[NSAnimationContext currentContext] setCompletionHandler:^{
[self.blob removeFromSuperview];
}];
setCompletionHandler:
是NSAnimationContext
类中的方法。
如果10.6或以下(因此NSAnimationContext的completionHandler
)不是这种方法只使用块和10.6+将工作的一个选项:
double delayInSeconds = 1.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[mySubView removeFromSuperview];
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.