Blurry SVG render when using HeroIcons in iOS app

Viewed 1505

I am using HeroIcons (https://github.com/tailwindlabs/heroicons) in my iOS app. I have added all SVG files into Resource bundle and able to render the SVG using SwiftUI.

But the rendered icon looks blurry

blurry

This is the SVG configuration

enter image description here

And this is the SwiftUI code snippet to display the icon

enter image description here

Any SVG export can help me with this?

3 Answers

Just select the “Preserve vector data” option in the image configuration, that should fix your issue.

I strongly believe there is something wrong with Image's rendering mechanism for SVG.

Following this question, I have adopted using UIImageView + UIViewRepresentable to render SVG and it works great.

You can take a look a similar implementation of a SwiftuI compatible UIImageView here: https://stackoverflow.com/a/61178828/452115

If the suggestion from David doesn't work, this might work then:

Image(uiImage: .init(named: "HeroIcons/outline/adjustments", in: Bundle.module, compatibleWith: nil))
       .resizable()
       ...
Related