Eventually solved it using a custom app delegate:
final class AppDelegate: NSObject, NSApplicationDelegate {
var openUrlCallback: ((_ url: URL) -> Void)?
func application(_ application: NSApplication, open urls: [URL]) {
for url in urls {
openUrlCallback?(url)
}
}
}
struct MyApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
Window("My App", id: "my_app") {
Text("Hi").onAppear {
appDelegate.openUrlCallback = { url in
print("Open URL", url)
}
}
}
}
}
Post
Replies
Boosts
Views
Activity
I don't think adjusting the image would help, because the alignment would be different on other devices with different screen sizes. It does center correctly when it doesn't ignore the safe area, so something must be going wrong with that.
To illustrate the difference, here are 2 screenshots:
The scaling works nicely, but the image is not centered anymore (it moves a bit to the right). Do you know how to fix that as well? Thanks!