Reputation: 689
I have NSWindow
:
_window = [[NSWindow alloc] init];
[_window setOpaque:NO];
[_window setBackgroundColor:[NSColor clearColor]];
[_window setStyleMask:NSBorderlessWindowMask];
And I have as its content view my custom view (without layer):
[_window setContentView:[[MyCustomView alloc] init]];
In drawRect:
of my custom view I create bezier path that looks like system popup and fill with color.
- (void)drawRect:(NSRect)dirtyRect
{
[NSGraphicsContext saveGraphicsState];
[super drawRect:self.bounds];
NSBezierPath *path = [self bodyShape];
[self.backgroundColor setFill];
[path fill];
[NSGraphicsContext restoreGraphicsState];
}
and all looks great
until I move popover place indicator. After redrawing in window appears artifacts, while drawRect:
of my custom view draws content right.
And when I draws content next time, this white triangle (see picture above) stay in same place in window and moves with window.
If I add to my view layer - all appears to be ok, but I can't add a layer.
If I fill my view with some solid color, there are no artifact.
I suggest that Cocoa caches first bitmap. But I do not sure why this happens and how to fix this. Maybe someone know why how fix to it?
Thanks.
Upvotes: 3
Views: 175
Reputation: 689
I found it! The problem is that the window caches shadow around place indicator. I fix it with calling invalidateShadow
method of NSWindow
.
Upvotes: 3