I'm making a macOS app using SwiftUI and I would like to minimise (hide) all open windows when I click a button.
Is this possible with SwiftUI and if so, how would I go about implementing this? Thanks
I'm making a macOS app using SwiftUI and I would like to minimise (hide) all open windows when I click a button.
Is this possible with SwiftUI and if so, how would I go about implementing this? Thanks
To minimize windows of your App currently, you could dip into AppKit
and iterate through NSApplication.shared.windows
to minimize each one. For example:
private func minimizeWindows() {
for window in NSApplication.shared.windows {
if window.isMiniaturizable {
window.miniaturize(nil)
}
}
}