Removing the Title Bar from Mac Catalyst App

Let’s learn how to remove the title bar from your Mac Catalyst app.

We are using Swift Programming Language.

The code will look something like this:

#if targetEnvironment(macCatalyst)
    if let titlebar = windowScene.titlebar {
        titlebar.titleVisibility = .hidden
        titlebar.toolbar = nil
    }
#endif

If your app is using SceneDelegate.swift file code will look something like this:

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

}

If your app is using AppDelegate.swift file code will look something like this:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
        
    #if targetEnvironment(macCatalyst)
    if let titlebar = window?.windowScene?.titlebar {
        titlebar.titleVisibility = .hidden
        titlebar.toolbar = nil
    }
    #endif

    return true
}

Hope this helps,

Thanks & Regards
Mandar Apte

One thought on “Removing the Title Bar from Mac Catalyst App

Leave a Reply

Your email address will not be published. Required fields are marked *