A baby window is what you need.
Create an NSWindow using NSBorderlessWindowMask and determine its transparency using the methods - setOpaque: and - setBackgroundColor: Then add the newly created window as a child of the window containing the NSWebView instance (using the NSWindow method - addChildWindow:ordered: . Moving the parent window will automatically move the child window.
Update using working code :
CGRect wRect = self.window.frame; NSView *contentView =self.window.contentView; CGRect cRect = contentView.frame; CGRect rect = CGRectMake(wRect.origin.x, wRect.origin.y, cRect.size.width, cRect.size.height); NSWindow *overlayWindow = [[NSWindow alloc]initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; overlayWindow.backgroundColor = [NSColor redColor]; [overlayWindow setOpaque:NO]; overlayWindow.alphaValue = 0.5f; [self.window addChildWindow:overlayWindow ordered:NSWindowAbove];
dzolanta
source share