由于某种原因,使用私有API CGSAddWindowFilter()的旧技巧似乎不再适用于Mavericks.我尝试了一些代码,如在OS X中的屏幕颜色反转如何工作?以下代码导致以下窗口.
#import "AppDelegate.h"
//Declarations to avoid compiler warnings (because of private APIs):
typedef void * CGSConnection;
typedef void * CGSWindowID;
extern OSStatus CGSNewConnection(const void **attributes, CGSConnection * id);
typedef void *CGSWindowFilterRef;
extern CGError CGSNewCIFilterByName(CGSConnection cid, CFStringRef filterName, CGSWindowFilterRef *outFilter);
extern CGError CGSAddWindowFilter(CGSConnection cid, CGSWindowID wid, CGSWindowFilterRef filter, int flags);
extern CGError CGSSetCIFilterValuesFromDictionary(CGSConnection cid, CGSWindowFilterRef filter, CFDictionaryRef filterValues);
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self.window setOpaque:NO];
[self.window setAlphaValue:1.0];
[self.window setBackgroundColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.1]];
self.window.level = NSDockWindowLevel; …Run Code Online (Sandbox Code Playgroud)