I am trying to make a transparent NSWindow with a rounded view.
I am trying to get a rounded view with a transparent window.
This is what it now looks like: (see small dots in the corners)

Here is another example with a border radius set to 10px (set to NSView drawRect):

I use the code from this Apple example: https://developer.apple.com/library/mac/#samplecode/RoundTransparentWindow/Introduction/Intro.html
Specifically, this method in my subclass of NSWindow:
- (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]; // Turn off opacity so that the parts of the window that are not drawn into are transparent. [self setOpaque:NO]; [self setBackgroundColor:[NSColor clearColor]]; } return self; }
And this is in my subclass of NSView:
- (void)drawRect:(NSRect)dirtyRect { [[NSColor redColor] set]; NSBezierPath* thePath = [NSBezierPath bezierPath]; [thePath appendBezierPathWithRoundedRect:dirtyRect xRadius:3 yRadius:3]; [thePath fill]; }
Can someone tell me what I am missing here?
Thanks.
source share