SVG to SwiftUI
SwiftUI's Path has no equivalent of the SVG elliptical arc, so any icon drawn with A commands has to be rewritten as cubic curves before it can be expressed at all. That conversion happens here. A single-colour icon becomes a Shape you can tint with foregroundStyle; a multi-colour one becomes a View layering one Shape per paint.
target
Paste or drop an SVG to preview it.
how to use it
- 01Paste SVG markup or drop an .svg file.
- 02Name the shape.
- 03Copy the Swift into your project.
questions
- Why a Shape sometimes and a View other times?
- A SwiftUI Shape carries a single fill, so it can only represent a one-colour icon. Anything with several colours needs a View stacking one Shape per paint.
- What happened to my arcs?
- They were converted to cubic Beziers, which is the only way to express them in SwiftUI. The curve is visually identical.
- How do I change its colour?
- For a Shape, apply foregroundStyle at the call site. A generated View carries its colours internally.