Loading...

How to keep an app's window always on top of others in Swift?

question macOS swift
Ram Patra Published on August 6, 2020
SDK - macOS 10.13+

Before launching the window, just use the appropriate window level, and you’re done.

For example,

window.level = NSWindow.Level.popUpMenu

Or, if you want a higher level:

window.level = NSWindow.Level.screenSaver

You can see all the window levels on Apple Documentation page.

Ram Patra Published on August 6, 2020
Image placeholder

Keep reading

If this article was helpful, others might be too

question macOS swift August 14, 2020 How to quit or close an app in macOS using Swift?

You can quit or exit an app with:NSApp.terminate(self)

May 28, 2020 Best Mac Apps for Working From Home

For me personally, it is a mixed feeling working from home. On one hand, I have the flexibility with when to work and when not to but on the other hand, it is sometimes hard for me to find that fine line between work and life. There are days when I keep working even after office hours without realizing that I have got my life wife too :)

question macOS swift March 14, 2021 How to detect Escape key pressed in macOS apps?

Like Delete key, detection of Escape key press is also slightly different than detecting general key presses.