Build
Codecov
Platforms
Swift 5.1
License
Twitter

Introduction

SVGPath is an open-source parser for the SVGPath syntax.

Installation

SVGPath is packaged as a dynamic framework that you can import into your Xcode project. You can install this manually, or by using Swift Package Manager.

Note: SVGPath requires Xcode 10+ to build, and runs on iOS 10+ or macOS 10.12+.

To install using Swift Package Manage, add this to the dependencies: section in your Package.swift file:

.package(url: "https://github.com/nicklockwood/SVGPath.git", .upToNextMinor(from: "1.0.0")),

Usage

You can create an instance of SVGPath as follows:

let svgPath = try SVGPath(string: "...")

Notice that the SVGPath constructor is a throwing function. It will throw an SVGError if the supplied string is invalid or malformed .

Once you have created an SVGPath object, in most cases you’ll want to convert this to a CGPath for rendering on Apple platforms. To do that you can use:

let cgPath = CGPath.from(svgPath: svgPath)

As a shortcut, you can create the CGPath directly from an SVG path string using:

let cgPath = try CGPath.from(svgPathString: "...")

Credits

The SVGPath library is primarily the work of Nick Lockwood.

(Full list of contributors)

GitHub

View Github