Search code examples
objective-cmacoscocoanswindownsshadow

Custom NSWindow with a custom shadow


I have a NSWindow subclass, looking like this

enter image description here

The thing that bothers me is that I would like to alter the shadow. Over a standard window, like Xcode right here, the contrast is a little weak.

So I'd like to apply a stronger NSShadow to it.

I found this here:

NSWindow with custom shadow

Apparently, you shouldn't, because the UI should mainly be handled by the OS. But the window is already completely custom, so I figured it would be ok.

How can I achieve this?


Edit

I forgot to mention, I know I could just redraw the NSWindow, but I try to avoid this.


Solution

  • There is no way, to my knowledge, to accomplish this without delving into private APIs.

    If you desperately want to change the shadow, the only way you can do this is if you set the root view in your window to have a layer, set a shadow on that layer, and inset the content to make space for the shadow. But this also brings a whole host of problems, including the window capturing clicks that were supposed to be for underlying windows, and resizing handles being off.