SwiftUI macos开发 程序最小化后点击dock栏无法还
2021-11-18 本文已影响0人
zhcnnet
转自https://github.com/writefreely/writefreely-swiftui-multiplatform
func applicationDidBecomeActive(_ notification: Notification) {
if let window = NSApp.windows.first {
window.deminiaturize(nil)
}
}
func applicationDidChangeOcclusionState(_ notification: Notification) {
if let window = NSApp.windows.first, window.isMiniaturized {
NSWorkspace.shared.runningApplications.first(where: {
$0.activationPolicy == .regular
})?.activate(options: .activateAllWindows)
}
}