I need to show an SVG image, loaded from JSON, into an image view, but I have 2 issues:
- JSON data contains a param BODY having the SVG code as string or null
Model
struct ResultItem: Codable{
let id: Int
let players: [ResultPlayer]
let body: String? //<------- Now it was fixed!
}
- How to use the SVG string in the image? I don't want to use any external lib but Xcode12 SVG
I would like to use the SVG to replace my current code:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
guard let vc = storyboard.instantiateViewController(withIdentifier: "Detail") as? DetailViewController else { return }
vc.selectedImage = "logo_2-mini.png"
self.present(vc, animated: true)
Can you help me using a string as an SVG image?
let svg = "<svg width=\"100\" height=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"green\" stroke-width=\"4\" fill=\"yellow\" /></svg>”.