'How to display SVG Templates in SwiftUI
I am trying to display an SVG Template in my SwiftUI app.
So, I have a var svgTemplate: String
variable in my SwiftUI App that contains an SVG Template string, an example is displayed below
"<svg width=\"1024\" height=\"440\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:
<!-- more data -->
xml:space=\"preserve\" text-anchor=\"start\" font-family=\"
Helvetica, Arial, sans-serif\" font-size=\"24\" id=\"svg_1\" y=\"151.52317\"
x=\"93.43789\" stroke-width=\"0\" fill=\"#000000\">This is sample svg template
</text>\n </g>\n</svg>"
Now, I want to render this SVG Template in my SwiftUI app, but I cannot figure out a way to do so.
I tried to convert my svgTemplate
to a base64StringImage
so that I can display a base64StringImage
by extending the Image View
, but I cannot find a way to convert my svgTemplate
to a base64StringImage
.
The other way I tried was just to display the svgTemplate
but that was unsuccessful as well.
Any kind of solution would be helpful.
Thank you in advance! :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|