【发布时间】:2021-03-29 00:40:57
【问题描述】:
我创建了一个简单的 macOS-only SwiftUI 应用程序,并根据Apple's instructions 添加了一个设置屏幕:
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
Settings {
SettingsView()
}
}
}
有效:Preferences 选项显示在应用菜单中。现在,我还想以编程方式打开此设置窗口,例如单击按钮时。有没有办法做到这一点?
我希望NSApplication 中有一个方法,类似于 About 窗口,但似乎没有。
【问题讨论】:
标签: macos swiftui window settings preferences