NSWindow non-rounded corner

How to make a window with non-rounded corner at bottom?

When I run a java app, it is non-rounded(sharp) corner at bottom, which is exactly what I want, how to make this with Cocoa API in Xcode?

I tried use NSBorderlessWindowMask, but it doesn't have title bar.

Please help!

Replies

If you ready to subclass NSWindow, this could help.

h ttps://developer.apple.com/library/content/samplecode/RoundTransparentWindow/Introduction/Intro.html#//apple_ref/doc/uid/DTS10000401-Intro-DontLinkElementID_2

Thanks, but as I mentioned above, I need standard title bar.

Well, you can subclass and still have standard titlebar.

The problem is: If I subclass and make the titlebar visible, the NSWindow would clip the content view using an hidden frame, which make the corner at bottom rounded. This is why I post here.

In the Apple's example, you have a drawRect (now should be draw).


That is where I would replace

NSRectFill([self frame]);


by a fill of the shape you create: round at top and square at bottom.

Thank you.

Apple's example don't have standard title bar. If I don't need title bar, of course I can easily subclass and define my own drawRect. As I said,

If I subclass and make the titlebar visible, the NSWindow would clip the content view to round.


Is there any Apple staff to help me?

Could you post the code of the subclass you tried, to see the problem :

"If I subclass and make the titlebar visible, the NSWindow would clip the content view to round."

You can download Apple's example and follow the steps:

1. In CustomWindow.m, remove -initWithContentRect method to make the titlebar visible.

2. In CustomView.m, change the drawRect mothod as follow:


- (void)drawRect:(NSRect)rect {

[[NSColor controlColor] set];

NSRectFill([self frame]);

return;

}


This simply fill a rect, but finally be clipped to round.

Any news on that?