Skip to content

doc: update swiftUI image extension helper in readme#833

Merged
Alex009 merged 1 commit into
icerockdev:masterfrom
pauarmada:doc/ios-image-extension
Jul 3, 2025
Merged

doc: update swiftUI image extension helper in readme#833
Alex009 merged 1 commit into
icerockdev:masterfrom
pauarmada:doc/ios-image-extension

Conversation

@pauarmada

@pauarmada pauarmada commented Jul 3, 2025

Copy link
Copy Markdown
Contributor

On SwiftUI, we should generate the Image directly from the ImageResource. Loading svgs by making a UIImage first causes scaling issues resulting in blurry images.

Above: Image(uiImage: MR.images()[keyPath: \.ic_close].toUIImage()!)
Bottom:

extension Image {
    init(resource: KeyPath<MR.images, ImageResource>) {
        let imageResource = MR.images()[keyPath: resource]
        self.init(imageResource.assetImageName, bundle: imageResource.bundle)
    }
}
Screenshot 2025-07-03 at 14 48 40

Using UIImage inside Image results in blurry svgs, so we should load the image directly to SwiftUI.Image
@Alex009 Alex009 changed the base branch from develop to master July 3, 2025 06:59
@Alex009 Alex009 merged commit 1b54291 into icerockdev:master Jul 3, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants