我有一段简单的 SwiftUI 代码来启动一个小型 NSWindow,如下所示。但是当窗口出现时,它非常小,并且会忽略最小尺寸。
...
Button("Test Window") {
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),styleMask: [.titled, .closable, .resizable, .miniaturizable],backing: .buffered, defer: false)
window.minSize = NSSize(width: 200, height: 400)
window.title = "Test Window"
window.contentView = NSHostingView(rootView: TestView())
window.center()
let windowController = NSWindowController(window: window)
windowController.showWindow(self)
}
...