UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Mac Catalyst

Forums > SwiftUI

In a Mac Catalyst app, there is a titlebar at the top, which just looks odd. Is there anyway in SwiftUI to get rid of the titlebar?

2      

Yes, in SwiftUI, you can remove the title bar from a Mac Catalyst app by setting the window style to .hiddenTitleBar.

Here is an example of how you can do this:

import SwiftUI

@main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() .frame(minWidth: 300, minHeight: 200) .windowStyle(.hiddenTitleBar) // Set the window style to hiddenTitleBar } .windowToolbarStyle(.unifiedCompact) // Optional: set the window toolbar style } }

struct ContentView: View { var body: some View { Text("Hello, world!") .padding() } }

In this example, the WindowGroup contains a ContentView with some text. We set the windowStyle to .hiddenTitleBar to remove the title bar from the app window.

Note that the .hiddenTitleBar style also removes the default close, minimize, and fullscreen buttons from the window. If you still want those buttons, you can use the .titleBar style instead and customize it to your liking.

2      

@phillipdtarrant_143

That doesn't seem to work. I am told that .windowStyle is not available in an iOS app. If I forgot to mention which I think I did. I am adding to my iOS app a supported destination of Mac Catalyst until I can write a proper macOS target.

2      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.