Home > Enterprise >  Mac Catalyst UITitleBar covers the UI -- how to resolve?
Mac Catalyst UITitleBar covers the UI -- how to resolve?

Time:01-13

When running an iPad Mac Catalyst iPad on macos, there is a title bar, which I don't mind. But it covers part of the UI, and to compensate I should shift my UI down by the height of that bar. I cannot find a way to find that height anywhere. I've tried querying it and its NSToolbar properties but nothing gives me this basic information.

I can hide the toolbar itself with no problem, using this:

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

This almost resolves the problem, as most of the UI is accessible once that title bar is gone, but the three upper left controls to close and zoom the window are still on top of UI elements.

How do you normally handle this problem?

CodePudding user response:

In order for your UI to avoid the title bar and other window chrome, it needs to respect safeAreaInsets, which tell your UI what area is safe to be drawn on without being covered by system UI.

  •  Tags:  
  • Related