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      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.