UIView
A set of convenience initializers that create new UIView
instances from SVG data
-
Convenience initializer that instantiates a new
UIView
instance with a single pathd
string. The path will be parsed synchronously.let view = UIView(pathString: "M20 30 L30 10 l10 10")
Declaration
Swift
public convenience init(pathString: String)
Parameters
pathString
The path
d
string to parse. -
Convenience initializer that instantiates a new
UIView
for the given SVG file in the main bundlelet view = UIView(SVGNamed: "hawaiiFlowers")
Declaration
Parameters
SVGNamed
The name of the SVG resource in the main bundle with an
.svg
extension or the name an asset in the main Asset Catalog as a Data Asset.parser
The optional parser to use to parse the SVG file
completion
A required completion block to execute once the SVG has completed parsing. The passed
SVGLayer
will be added to this view’s sublayers before executing the completion block -
Convenience initializer that instantiates a new
UIView
instance for the given SVG file at the given URLUpon completion, it will resize the layer to aspect fit this view’s superview
let view = UIView(SVGURL: "hawaiiFlowers", parser: aParser) { (svgLayer) in // Do something with the passed svgLayer }
Declaration
Parameters
SVGURL
The local or remote
URL
of the SVG resourceparser
The optional parser to use to parse the SVG file
completion
A required completion block to execute once the SVG has completed parsing. The passed
SVGLayer
will be added to this view’s sublayers before executing the completion block -
Convenience initializer that instantiates a new
UIView
instance with the given SVG dataUpon completion, it will resize the layer to aspect fit this view’s superview
let view = UIView(SVGData: svgData)
Declaration
Parameters
SVGData
The SVG
Data
to be parsedparser
The optional parser to use to parse the SVG file
completion
A required completion block to execute once the SVG has completed parsing. The passed
SVGLayer
will be added to this view’s sublayers before executing the completion block