In the past I've been successfully able to fade in an NSWindow using the following code;
if (![statusWindow isVisible])
{
statusWindow.alphaValue = 0.0;
[statusWindow.animator setAlphaValue:1.0];
}
CAAnimation *anim = [CABasicAnimation animation];
[anim setDelegate:self];
[statusWindow setAnimations:[NSDictionary dictionaryWithObject:anim forKey:@"alphaValue"]];
[statusWindow makeKeyAndOrderFront:self];
For my current project I'm trying to make a flash similar to the one in Photo Booth. I've created a white NSPanel and was planning to set my NSWindow's content to the panel, and quickly set it back.
Is it possible to set the contentView of 开发者_开发百科an NSWindow using a nice fade effect?
P.S - If there is an easier way you know of how to achieve the flash, please tell me!
Thanks in advance, Ricky.
Why use another window? It looks like you're trying to use CoreAnimation already so why not just add a white CALayer to your existing view and animate its opacity?
精彩评论