Transparent NSWindow, but with a standard border and shadow

I want to have a more or less standard NSWindow with a toolbar and all that, but I want the content view to be transparent so that I can see it. At the same time, I want to keep the light gray outline of the window, as well as the shadow. BUT, I want to avoid the โ€œinnerโ€ shadow that I get from the toolbar inside the content viewport.

What I have tried so far is simply to set the background color of the window to a translucent color, and also set the opacity to NO. The problem is that the window border disappears with the alpha of the background itself, and the more transparency I have in the background, the more the shadow of the toolbar appears within the content.

As a rule, the shadows and borders of the window change depending on the transparency of the content, which I fully understand. But I need a behavior in which it retains the border and shadow, as if it were a completely opaque window, and then I want the content viewport to be transparent.

I'm not sure what I need to do conceptually to make it work. Maybe I need to draw the border of the window, maybe not. Maybe I need to draw a shadow myself, or maybe not.

Is there anyone who knows how to do this? I do not need the exact code data, but what parts I need to do in the usual way.

I appreciate any input!

+4
source share
2 answers

I don't know if this is really for you all this time, but try:

[aWindow setOpaque:NO]; [aWindow setBackgroundColor:[NSColor clearColor]]; 
+3
source

A subclass of the NSView class overrides the drawRect: (NSRect) dirtyRect method and sets the view color as clearcolor, now set the class of your content view as a subclass of NSView.

0
source

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


All Articles