简体   繁体   English

在主窗口上更改Alpha-可可

[英]Change Alpha on Main Window - Cocoa

I want to know if I can slowly increase the alpha MainWindow when I open the app and when I close the app. 我想知道在打开应用程序和关闭应用程序时是否可以缓慢增加Alpha MainWindow。 I know it may involve timers, and things like that, but I never dealt with this kind of thing before. 我知道它可能涉及计时器,以及类似的事情,但是我以前从未处理过这种事情。 I need your help guys...! 我需要你们的帮助...!

Kevin 凯文

Use NSViewAnimation. 使用NSViewAnimation。 Despite the name, it works on windows as well as views. 尽管有名称,它在Windows以及视图上均可使用。

[self setAlphaValue:0]; [self setAlphaValue:0];

That'll set the alpha of the window. 这将设置窗口的Alpha。 Just create an NSTimer that either adds or subtracts to bring the alpha up or down. 只需创建一个NSTimer即可添加或减去以提高或降低Alpha。 The Value is an <#(CGFloat)windowAlpha#>. 值是<#(CGFloat)windowAlpha#>。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM