這是官方鏈接:https ://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst?language=objc
我不知道如何將代碼翻譯成 Objective-C。頁面頂部有一個選項,但它不起作用。
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
}
uj5u.com熱心網友回復:
在SceneDelegate.h中將這段代碼添加到場景中:WillConnectToSession:options:方法:
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
#if TARGET_OS_MACCATALYST
// Code specific to Mac.
[(UIWindowScene *)scene titlebar].titleVisibility = UITitlebarTitleVisibilityHidden;
[(UIWindowScene *)scene titlebar].toolbar = nil;
#else
// Code to exclude from Mac.
#endif
}
有用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/477646.html
