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.

Presentify

Take your presentation to the next level.

FaceScreen

Put your face and name on your screen.

ToDoBar

Your to-dos on your menu bar.

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 macOS swift August 14, 2020 How to detect Delete key press in Swift?

Delete key press detection is slightly different than other keys. It uses NSDeleteCharacter like below:

question macOS swift August 6, 2020 How to open an app's window on top of all others in Swift?

You can open your app’s window on top of all other open application windows with the below code: