此叠加层应位于所有其他 GUI 项目之上(如 CMD-Tab 叠加层).你知道如何有效地做到这一点吗?目前我正在玩这种代码:int windowLevel = CGShieldingWindowLevel();NSRect windowRect = [[NSScreen mainScreen] frame];NSWindow *overlayWindow = [[NSWindow alloc] initWithContentRect:windowRectstyleMask:NSBorderlessWindowMask支持:NSBackingStoreBuffered推迟:否屏幕:[NSScreen mainScreen]];[overlayWindow setReleasedWhenClosed:YES];[overlayWindow setLevel:windowLevel];[overlayWindow setBackgroundColor:[NSColor colorWithCalibratedRed:0.0绿色:0.0蓝色:0.0阿尔法:0.5]];[overlayWindow setAlphaValue:1.0];[overlayWindow setOpaque:NO];[overlayWindow setIgnoresMouseEvents:NO];[overlayWindow makeKeyAndOrderFront:nil];...它工作正常,但我没有选择启动任何类型的动画,例如缓慢增加透明度(缓慢调暗屏幕)等.虽然我不明白如何把这个窗口放在后台,不释放它,让它不时弹出.那么有没有更好或标准"的方法来做到这一点? 解决方案 您可以使用 NSViewAnimation.是的,它也适用于 Windows.动画的目标应该是窗口,其效果应该是淡入或淡出,具体取决于您是显示还是隐藏它.省略框架键,因为您可能不想移动或调整窗口大小.当然,您应该省略 makeKeyAndOrderFront: 消息,因为您将使用淡入效果对其进行排序.I'm searching for the "best" way of creating a fullscreen overlay under Mac OS X. I want to create a transparent or semi-transparent overlay, which cares about mouse events and shows other input/output elements.This overlay should be above every other GUI items (like the CMD-Tab overlay).Do you know how to do it effectively? At the moment I'm playing around with this kind of code:int windowLevel = CGShieldingWindowLevel();NSRect windowRect = [[NSScreen mainScreen] frame];NSWindow *overlayWindow = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:[NSScreen mainScreen]];[overlayWindow setReleasedWhenClosed:YES];[overlayWindow setLevel:windowLevel];[overlayWindow setBackgroundColor:[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.5]];[overlayWindow setAlphaValue:1.0];[overlayWindow setOpaque:NO];[overlayWindow setIgnoresMouseEvents:NO];[overlayWindow makeKeyAndOrderFront:nil];…and it works fine but I've got no options to initiate any kind of animations like slowly increasing the transparency (slowly dimming the screen) etc.Although I'm not understanding how to put this window in the background, without releasing it and let it pop up time to time.So is there a better or "standard" way to do it? 解决方案 You can use NSViewAnimation. Yes, it works on windows, too.Your animation's target should be the window, and its effect should be fade-in or fade-out, depending on whether you're showing or hiding it. Leave out the frame keys, since you probably don't want to move or resize the window.Of course, you should leave out the makeKeyAndOrderFront: message, since you'll be ordering it front with the fade-in effect. 这篇关于在 Mac OS X (Lion) 上创建全屏覆盖的最优雅方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-24 07:34