I have an borderless subclass of NSWindow
with custom graphics with rounded corners:
MyCustomWindow:
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
if (self) {
// 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 setMovableByWindowBackground:YES];
}
return self;
}
- (BOOL) canBecomeKeyWindow
{
return YES;
}
MyCustomView:
- (void)drawRect:(NSRect)rect {
[[NSColor clearColor] set];
NSRectFill([self frame]);
[backgroundImage compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
}
However, every once in a while (maybe 1 out of 10) when I start the application the graphics looks wrong because I get an grey one-pixel square border around the window. It is not set around my custom graphics but around the window's frame, which means that it negates my round corners.
Is there something I am missing in my subclasses?
EDIT: Here is a screenshot of the issue: