NSWindow with bottom corners rounded
I have subclassed NSWindow so I can make some tweaks and have a custom window. One of them is to make bottom corners rounded but haven't succeed yet.
I have tried this but my window does not have the standard sta开发者_高级运维tus bar it didn't work. I hope this is possible ;)
Thanks in advance
Since my window has style: NSBorderlessWindowMask
I have solved this by subclassing containerView of the window and overriding drawRect:
- (void) drawRect:(NSRect)dirtyRect{
[[NSColor windowBackgroundColor] set];
[NSGraphicsContext saveGraphicsState];
NSBezierPath *path;
path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:5 yRadius:5];
... // do more fancy stuff here ;)
[NSGraphicsContext restoreGraphicsState];
}
Use this in the delegate of the window:
- (void)awakeFromNib
{
[window setContentBorderThickness:32.0 forEdge:NSMinYEdge];
}
Alternately you can set this behavior in Xcode 4 on a window in the size inspector at ContentBorder
. This will make the window look like this:
精彩评论