【发布时间】:2021-09-17 04:07:24
【问题描述】:
我是 swift 新手,我正在制作一个菜单栏应用程序。如何让用户通过拖动窗口的角来调整窗口大小?到目前为止我只知道如何设置固定的高度和宽度popover.contentSize = NSSize(width: 890, height:890)
应用委托
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
var popover = NSPopover.init()
var statusBar: StatusBarController?
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Create the SwiftUI view that provides the contents
let contentView = ContentView()
popover.contentViewController = MainViewController()
popover.contentSize = NSSize(width: 890, height:890)
popover.contentViewController?.view = NSHostingView(rootView: contentView)
popover.animates = false
// Create the Status Bar Item with the Popover
statusBar = StatusBarController.init(popover)
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}
【问题讨论】:
标签: swift swiftui menubar nspopover