Closed breynolds closed 2 years ago
WebImage does not supports dynamic size changes for vector image. (SVG)
If you really want what UIImageView
do, try using AnimatedImage
, which is backed by UIKit, not SwiftUI.
Or, you can use .context(.imageThumbnailPixelSize)
to provide a CGSize to parse SVG as bitmap image.
Seems this issue has been solved ?
When I load in an image into WebImage in SwiftUI using SDWebImageSwiftUI, it's supposed to use the default size of the image as specified by the file unless I change it using the resizable and frame modifiers. However, I'm loading an SVG image in that has a height of 55, but when I display it, the image displayed is not 55 and is instead being blown up to a much larger size.
This should work: WebImage(url: URL(string: "https://qonsent.dev3.granitedata.io/assetsPublic/logo-allstate.svg"))
But instead I'm having to use this code which isn't good enough because some images are not 55 in height so this doesn't work for all of the images we have. WebImage(url: URL(string: "https://qonsent.dev3.granitedata.io/assetsPublic/logo-allstate.svg")) .resizable() .scaledToFit() .frame( maxHeight: 55, alignment: .center)
Please add in support to correctly size an image based on the height and width inside of the SVG file.