Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait for an animator to finish?

This is probably a simple question but I can't seem to figure out how to do it. Basically all I want to do is fade a window before closing it:

[[window animator] setAlphaValue:0.0];
[window close];

This works fine without the [window close], but when that is included the window seems to close it before the animation finishes (which is obviously not what I want); the same seems to happen for orderOut:, performClose:, etc. Is there any way to avoid this?

like image 903
Michael Avatar asked Jul 03 '09 04:07

Michael


1 Answers

[[window animator] setAlphaValue:0.0];
[window performSelector:@selector(performClose:) withObject:self afterDelay:[[NSAnimationContext currentContext] duration]];
like image 190
Tom Dalling Avatar answered Sep 25 '22 22:09

Tom Dalling