【发布时间】:2020-06-12 20:17:29
【问题描述】:
如何从 NSWindow 访问 SwiftUI Catalyst 应用程序的属性?例如,允许通过 NSWindow.moveableByWindowBackground 拖动窗口背景来移动窗口。
我已经在 SceneDelegate.swift 中指定了基础知识。
import UIKit
import SwiftUI
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let app = UIApplication.shared
let delegate = app.delegate as! AppDelegate
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
#if targetEnvironment(macCatalyst)
if let titlebar = windowScene.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
if let sizeRestrictions = windowScene.sizeRestrictions {
sizeRestrictions.minimumSize = CGSize(width: 1300, height: 800)
}
window.canResizeToFitContent = true
#endif
window.rootViewController = UIHostingController(rootView: GreatHallView(screenerVM: delegate.screenerVM).environmentObject(SortingHat()))
self.window = window
window.makeKeyAndVisible()
}
}
【问题讨论】:
标签: swiftui nswindow mac-catalyst