如何在新的SwiftUI App协议中隐藏标题栏?
由于AppDelegate.swift和SceneDelegate.swift协议已经消失,我不能再遵循这份文档了: https://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst
我无法实现这段代码:
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
#if targetEnvironment(macCatalyst)
if let titlebar = windowScene.titlebar {
titlebar.titleVisibility = .hidden
titlebar.toolbar = nil
}
#endif
}
}
希望新的AppProtocol仍然可行。谢谢提前。
withHostingWindow
(来自 https://dev59.com/EFIG5IYBdhLWcg3wtjy2#63276688)来查找自己的窗口,然后执行所需操作。 - Asperi