Martin Mlostek
Martin Mlostek

Reputation: 2970

NSPanel borderless but always on top

I am trying to make a NSPanel that looks like this

borderless

This is initialized like that

        let panel1 = NSPanel(contentRect: frame1,
                             styleMask: [.borderless],
                             backing: .buffered,
                             defer: true)

The thing is, when I click anywhere on the screen outside of that panel, it disappears. Only when i click on the application icon again, it comes to foreground.

With the following implementation I am getting the panel to stick on top, but there its having a border

        let panel1 = NSPanel(contentRect: frame1,
                             styleMask: [.borderless, .nonactivatingPanel],
                             backing: .buffered,
                             defer: true)

The border (few black pixels) looks like this but is always on top.

border

The question

How can I have it borderless (like the first image) but always on top (like the 2nd image).

Notes

Upvotes: 0

Views: 442

Answers (1)

Curious Fishel
Curious Fishel

Reputation: 31

I know it's been a while, but for whoever is struggling, simply add hasShadow = false that will do the trick.

Upvotes: 3

Related Questions