How to create window without border between title bar and content view?

I'm trying to achieve the look seen below in Xcode's about window, where there is no border between the title bar of the window and the content view, but I can't seem to get rid of the border between the title bar and the content view.

This is my code:

struct MyView: View {
    var body: some View {
        HStack {
            Text("Hello world")
        }
        .frame(width: 200, height: 200)
    }
}

...

myWindow = NSWindow(
    contentRect: NSRect(x: 0, y: 0, width: 200, height: 200),
    styleMask: [.closable, .titled],
    backing: .buffered, defer: false)
myWindow.contentView = NSHostingView(rootView: MyView())

Which results in:

This style of window is without the title bar. You would need to remove/hide it to get this effect.

In SwiftUI, you would add this modifier to your main App:

WindowGroup {
    ContentView()
}
.windowStyle(.hiddenTitleBar) // add this modifier here


However, it seems like you are using the AppKit lifecycle which means you will have to do this:

myWindow = NSWindow(
    contentRect: NSRect(x: 0, y: 0, width: 200, height: 200),
    styleMask: [.closable, .titled, .fullSizeContentView], // can make the contentView consume the full size of the window
    backing: .buffered, defer: false)

// Modify these two properties
myWindow.titleVisibility = .hidden
myWindow.titlebarAppearsTransparent = true

Works like a charm, huge thanks @BabyJ!

How to create window without border between title bar and content view?
 
 
Q