I'm trying to convert my svg
image data to UIImage
instance using SVGKit
, but when I'm trying to do this its getting crashed, and the error message is like below:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Asked to convert a Percentage value to a different type (5)'
Here is the code for svg
to UIImage
conversion.
if let data = response.data {
if let image = SVGKImage(data: data) {
if let uiImageInstance = image.uiImage {
self.userImageView.image = uiImageInstance
}
}
}
Its getting crashed at this line
-> if let uiImageInstance = image.uiImage {
I'm using AlamofireImage
library for downloading my image data from server.
I have checked that my svg
data is there in response.
FYI: My image is combination of avatar letters and gradient background.
See below image for reference.
My svg image sample URL: Link
Any help?
Thanks in advance.
If you are image is using gradient effect then it will not work in SVGKit. Check whether your image is using any gradient effect.
Apple's rendering DOES NOT ALLOW US to render this image correctly using SVGKFastImageView, because Apple's renderInContext method - according to Apple's docs - ignores Apple's own masking layers. Until Apple fixes this bug, you should use SVGKLayeredImageView for this particular SVG file (or avoid using gradients)