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.

Take your presentation to the next level.

Put your face and name on your screen.

Your to-dos on your menu bar.

Fill forms using your right-click menu.

Ram Patra Published on August 6, 2020
Image placeholder

Keep reading

If this article was helpful, others might be too

question macOS swift March 14, 2021 How to ignore mouse events in a view or window in macOS?

You can ignore mouse events in a window/view by adding just a single line of code.

question swift macOS October 29, 2023 How to make Color conform to RawRepresentable in SwiftUI in macOS?

For various reasons you may want to convert the Color type to a String. And, below is a relatively cleaner way to do it.

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)

Like my work?

Please, feel free to reach out. I would be more than happy to chat.