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 anim
This is an old (but still popular) question with obsolete answer.
The right way to wait for animator finished is using special NSAnimationContext
's class method with completionHanler
like this:
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
// Start some animations here.
[[window animator] setAlphaValue:0.0];
} completionHandler:^{
// This block will be invoked when all of the animations started above have completed or been cancelled.
NSLog(@"All done!");
}];
Implicit animations triggered through the animator proxy run on wall time. Get the duration from the current NSAnimationContext and perform delay your cleanup/post-animation operations using that interval.
[[window animator] setAlphaValue:0.0];
[window performSelector:@selector(performClose:) withObject:self afterDelay:[[NSAnimationContext currentContext] duration]];