I'm wanting to achieve a corner radius on my NSWindow that has no title bar or miniaturizable set. I've had to override NSWindow's canBecomeKey in order to make views in the window selectable.
I've seen lots of ways to achieve this for older versions of swift or those that use interface builder but I'm using swiftUI.
This is my NSWindow override:
class SWindow: NSWindow {
override var canBecomeKey:Bool {
return true
}
}
In App Delegate:
var searchWindow: SWindow!
let searchView = SearchView().cornerRadius(10)
searchWindow = SWindow(
contentRect: NSRect(x: 0, y: 0, width: 850, height: 500),
styleMask: [.resizable],
backing: .buffered, defer: false)
searchWindow.center()
searchWindow.isReleasedWhenClosed = false
searchWindow.isMovableByWindowBackground = true
searchWindow.titlebarAppearsTransparent = true
searchWindow.isOpaque = false
searchWindow.contentView = NSHostingView(rootView: searchView)
searchWindow.makeKeyAndOrderFront(true)
Adding the SearchView().cornerRadius(10) does seem to create a corner radius on the view but the window is still square.