Mandar Apte

UI/UX Designer from Mumbai, Maharashtra, India.

Removing the Title Bar from the Mac Catalyst App

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
}

I hope this helps,

Thanks & Regards
Mandar Apte

Comments

One response to “Removing the Title Bar from the Mac Catalyst App”

  1. Thomas Macbach Avatar
    Thomas Macbach

    How to do this in Objective-C, please?

Leave a Reply

Sponsors


Search