Here's the official link: https://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst?language=objc
I can't figure out how to translate the code to Objective-C. There's an option on the top of the page but it doesn't work.
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
}
CodePudding user response:
Inside SceneDelegate.h add this code to the scene:WillConnectToSession:options: method:
- (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
}
It works.