Before El Capitan, this code was working exactly how it should. Now my window is not transparent anymore, it's white.
NSWindow* window = [[NSWindow alloc] initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO];
[window setOpaque:NO];
[window setBackgroundColor:[NSColor clearColor]];
Any ideas ? Thanks for the help.
I am not sure where you put the code, but the following worked for me.
NSWindow
subclass-
- (id)initWithContentRect:(NSRect)contentRect
styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag {
// Using NSBorderlessWindowMask results in a window without a title bar.
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
if (self != nil) {
// Start with no transparency for all drawing into the window
[self setAlphaValue:1.0];
//Set backgroundColor to clearColor
self.backgroundColor = NSColor.clearColor;
// Turn off opacity so that the parts of the window that are not drawn into are transparent.
[self setOpaque:NO];
}
return self;
}
This code is from Apples Sample Code Page - Round Transparent Window
You used NSBackingStoreNonretained
as the window backing. According to the docs:
You should not use this mode. It exists primarily for use in the original Classic Blue Box. It does not support Quartz drawing, alpha blending, or opacity. Moreover, it does not support hardware acceleration, and interferes with system-wide display acceleration. If you use this mode, your application must manage visibility region clipping itself, and manage repainting on visibility changes.
So it simply does not support transparent windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With