过去,我可以使用以下代码成功淡入NSWindow。

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];


对于我当前的项目,我正在尝试制作类似于Photo Booth中的闪光灯。我创建了一个白色的NSPanel,并计划将NSWindow的内容设置为面板,然后快速将其重新设置。

是否可以使用良好的淡入淡出设置NSWindow的contentView?

附注-如果您有更简单的方法来了解如何实现闪光灯,请告诉我!

提前致谢,
瑞奇

最佳答案

为什么要使用另一个窗口?看起来您已经在尝试使用CoreAnimation了,为什么不只在现有视图中添加白色CALayer并为其不透明度设置动画呢?

10-07 18:34