Recently I had the need to show a logo in SVG format, but the project required that we did not include 3rd party libraries. The following Swift playground shows how you can show an SVG-based image using WKWebView.
Somehow, you need to know the image size beforehand -- or at least you need to be able to set width and height constraints. Lots of logos are square, thus there's no need to do anything special.
import UIKit import PlaygroundSupport import WebKit
class MyViewController : UIViewController { override func loadView() { let view = UIView() view.backgroundColor = .white
let webView = WKWebView() webView.translatesAutoresizingMaskIntoConstraints = false
let header = """ <!DOCTYPE html><html style=\"overflow: hidden\"> <head> <meta name="viewport" content="initial-scale=1.0" /> <title>icon_people_search</title> </head> <body style=\"margin: 0;\"> """ let footer = """ </body> """ let svg = """ <?xml version="1.0" encoding="iso-8859-1"?> <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 495 495" style="enable-background:new 0 0 495 495;" xml:space="preserve"> <g> <polygon style="fill:#1A6FB0;" points="247.5,0 247.5,40 455,40 455,455 247.5,455 247.5,495 495,495 495,0 "/> <polygon style="fill:#1E81CE;" points="40,455 40,40 247.5,40 247.5,0 0,0 0,495 247.5,495 247.5,455 "/> <path style="fill:#1E81CE;" d="M205.767,405h65.266V247.413h43.798c0,0,4.104-25.428,6.103-53.235h-49.647v-36.264 c0-5.416,7.109-12.696,14.153-12.696h35.564V90h-48.366c-68.478,0-66.872,53.082-66.872,61.009v43.356h-31.771v53.029h31.771V405z" /> </g> </svg> """ webView.loadHTMLString(header + svg + footer, baseURL: Bundle.main.bundleURL) view.addSubview(webView) let constraints = [ webView.widthAnchor.constraint(equalToConstant: 100), webView.heightAnchor.constraint(equalToConstant: 100), webView.centerXAnchor.constraint(equalTo: view.centerXAnchor), webView.centerYAnchor.constraint(equalTo: view.centerYAnchor) ] view.addConstraints(constraints) self.view = view } } // Present the view controller in the Live View window PlaygroundPage.current.liveView = MyViewController()