macOS swiftui navigation causes close/min/max buttons to shift around

Does anyone know a good fix for this?

Previously, I fixed this by adding a toolbar items in every view (which isn't ideal, because I don't always have an action for the user to perform). But in this app I'm experiencing an issue where swift-frontend starts eating 10s of gigs of memory if I add toolbar items to one of my views that contains a form, and then I get this error: "Command CompileSwiftSources failed with a nonzero exit code" — which doesn't Google to anything related to my circumstance.

So that's preventing this work around (which is extra unfortunate, because in this case I do have an action for my users to perform).

Googling "swiftui macOS set title bar height manually" also doesn't turn up anything remotely relevant, but I think that's what I want to do.

Answered by subcreation in 688792022

Okay, so what worked for me was to include the toolbar with buttons in the screens which don't require buttons and then to hide them with an opacity modifier set to 0.0, like so:

Button(action: {}) {
    Label("Share", systemImage: "square.and.arrow.up")
}
    .opacity(0.0)
Accepted Answer

Okay, so what worked for me was to include the toolbar with buttons in the screens which don't require buttons and then to hide them with an opacity modifier set to 0.0, like so:

Button(action: {}) {
    Label("Share", systemImage: "square.and.arrow.up")
}
    .opacity(0.0)
macOS swiftui navigation causes close/min/max buttons to shift around
 
 
Q