0

I have used SVGKit library to show svg images but the is some extra numbering in the images.

Here is the actual image:

enter image description here

But the image shown in the imageView looks like this:

enter image description here

As you can see in second image the numbers are showing on top and bottom in bunches are not part of the original image.

How do I resolve this issue.I am using the svg image first time so I don't know the reason behind this.

Here is the code to show svg image from url:

let svgURL = URL(string: imageUrl)
let data = try? Data(contentsOf: svgURL)
let receivedIcon: SVGKImage = SVGKImage(data: data)
                        self.svgImageView.image = receivedIcon.uiImage
Zahid Shaikh
  • 37
  • 10
  • Please add the code for svgView. It is likely that your sgView's frame size is not set the way you want it to be. You can also try scale aspect fill on both your webview and the svg. Try changing the background color of your views like webView and svgView to see their frame sizes. – Jazure Jul 10 '18 at 13:11
  • I am setting the svg image in two ways the first is 3rd party library in which image size is perfectly fine but some image parts are missing(see image 2nd).But while using wkwebview the image shown is too small(Image 1st). – Zahid Shaikh Jul 10 '18 at 13:20
  • Try changing the color of your webView. It will show you how big the frame is. Does it cover the screen? If it doesn't cover your screen, then you need to change the frame of your webView. – Jazure Jul 10 '18 at 13:31
  • Also the problem might be with the html file. In your third party library, your SVG is being resized. UIWebView might have trouble with sizing. Try and see how other people have loaded SVGs using UIWebView. – Jazure Jul 10 '18 at 13:38

1 Answers1

0

You code is perfectly fine. If there is no issue with the SVG image, image will display surely. The issue is not with the WKWebView, issue is with the coding of SVG image. As we know that SVG is made of a html css code.., try to fix that css part.

Also please open your image link in browser and try to reduce the width height of the window, if css issue is there, surely your image will be displayed distorted.

Also follow this issue too.

Mradul Kumar
  • 347
  • 3
  • 17