6

Hi is there a way to change the window level with SwiftUI so I can make a floating window for my mac app? I am using the SwiftUI life cycle

1 Answers1

6

You can access your windows with NSApplication.shared.windows and set the level for each one.

For instance:

Button("Float windows") {
    for window in NSApplication.shared.windows {
        window.level = .floating
    }
}
Alexander Sandberg
  • 1,265
  • 11
  • 19