I am trying to set the initial position of my app window. I have tried NSViewRepresentable and setFrameTopLeftPoint as shown below with no success. Is my syntax incorrect or do I need to utilize a different method?
struct WindowAccessor: NSViewRepresentable {
@Binding var window: NSWindow?
func makeNSView(context: Context) -> NSView {
let view = NSView()
view.window?.setFrameTopLeftPoint(CGPoint(x: 0, y: 0))
DispatchQueue.main.async {
self.window = view.window
}
return view
}
func updateNSView(_ nsView: NSView, context: Context) {}
}
and
var body: some Scene {
WindowGroup {
ContentView()
.background(WindowAccessor(window: $window))
}
}