I'm trying to create a custom NSWindow where I want my content to completely fill the available space, I have managed to hide the navigation bar buttons and title and make it transparent, but when I set the content to fill the available space there is some space at the bottom that is not working
The way I create my window:
private func createWindow() -> MyWindow {
let window = MyWindow(
contentRect: NSRect(x: 0, y: 0, width: 10, height: 10), // these values don't matter, the window expands to the swiftUI view
styleMask: [.titled, .closable, .fullSizeContentView],
backing: .buffered, defer: false)
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.isMovableByWindowBackground = false
window.isReleasedWhenClosed = false
window.collectionBehavior = [.transient, .ignoresCycle]
window.standardWindowButton(.closeButton)?.isHidden = true
window.standardWindowButton(.zoomButton)?.isHidden = true
window.standardWindowButton(.miniaturizeButton)?.isHidden = true
return window
}
And on my component, I added the following property:
.ignoresSafeArea()
I already followed all the suggestions in this question but nothing seems to work on my case, any help is appreciatted
It looks I've reproduced what you might have
window.contentView =
NSHostingView(rootView:
Rectangle().fill(Color.red)
.ignoresSafeArea() // << works !!
.frame(width: 640, height: 480)
// .ignoresSafeArea() // << issue when here !!
)
More findings: no issue even with ignoresSafeArea
at the end when to use min W/H instead of strict frame for window, ie.
.frame(minWidth: 640, minHeight: 480)
.ignoresSafeArea()