1
votes

I have a NSWindow where I set opaque attribute to NO. The problem is that when I put any view inside that window it's corners has blank pixels.

Everything works well when opaque attribue is left with YES value, however, window's corners are not rounded anymore. See picture:

I've created repository with simple example project at bitbucket: https://bitbucket.org/lukaszb/animationartifacts

Is there a way I can fix this (remain window's corners rounded and blank pixels not appearing)? Or should I try another solution (without setOapque:NO at NSWindow subclass)?

2

2 Answers

1
votes

Try enabling the Core Animation layer for your RoundedView, i.e., open MainMenu.xib, select RoundedView and in the “View Effects” tab (rightmost one) check the view under “Core Animation Layer”.

Alternatively you can do it programmatically, e.g., in RoundedView add:

- (void)awakeFromNib {
    self.wantsLayer = YES;
    self.layer = [CALayer layer];
    self.layer.backgroundColor = [[NSColor blackColor] CGColor];
    self.layer.cornerRadius = RADIUS;
}

Also #import <QuartzCore/QuartzCore.h> and add QuartzCore.framework to the project. You can then delete the drawRect method since CALayer already does rounded corners for you. (Actually you can delete your whole RoundedView class if you just set up this layer for a regular NSView that you use in its place.)

0
votes

You can create a Subclass of NSView, make a custom drawing using NSBezierPath in it's drawRect: method, and then set it as the content view of the window.