Post

Replies

Boosts

Views

Activity

Reply to onOpenURL not called for single-window Mac OS application
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) } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24
Reply to Background image scales incorrectly when ignoring safe area
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!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to Background image scales incorrectly when ignoring safe area
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:
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to onOpenURL not called for single-window Mac OS application
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) } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
May ’24