nacho4d
nacho4d

Reputation: 45088

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 status bar it didn't work. I hope this is possible ;)

Thanks in advance

Upvotes: 1

Views: 3161

Answers (2)

yan.kun
yan.kun

Reputation: 6908

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:

NSWindow with set content border

Upvotes: 4

nacho4d
nacho4d

Reputation: 45088

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];
}

Upvotes: 5

Related Questions