Borderless NSWindow with rounded corners

I create a custom NSWindow without a header and use NSBorderlessWindowMask to make it completely borderless. However, the problem with this is that the window has sharp edges. In addition, there is no size control.

How would I give rounded corners without borders?

This is not a duplicate of this question , since this question was more about removing the header and there are currently no answers.

+4
source share
1 answer

You can make the window completely transparent and draw everything yourself. The sample I have is for OpenGL presentation, but it should work for Quartz or Cocoa as well.

Add the following to the initializer of the NSWindow subclass in which you create a new window using the NSBorderlessWindowMask constant.

 [self setOpaque:NO]; [self setBackgroundColor:[NSColor clearColor]]; 

You may have to draw a size control yourself. The sample I took this from is a full-screen window, so resizing is not required.

Good luck.

+7
source

Source: https://habr.com/ru/post/1334197/


All Articles