A small example on using NSWindow.Level in SwiftUI on MacOS

alt text


  1. Download & compile
  2. Run!
    • To change levels, select one and refresh!
    • To visit Apple’s documentation, press the “documentation” button!

Do It Yourself!

Maybe you don’t want to download the project. That’s fine! Here’s a minimal example:

func setLevel(level: NSWindow.Level) {
    for window in NSApplication.shared.windows {
        window.level = level

This is a function that you can put in the app you’re making. The available values for the “level” variable in the function are:


Additionally, you can use NSWindow.Level(rawValue: NSWindow.Level.normal.rawValue - 1) to make the window always stay below other windows.


Thank you very much to those who made/answered these sources!


View Github