CALayer
public extension CALayer
A set of convenience initializers that create new CALayer
instances from SVG data.
If you choose to use these initializers, it is assumed that you would like to exercise a higher level of control. As such, you must provide a completion block and then add the passed SVGLayer
to the layer of your choosing. Use the UIView extensions if you prefer the easier to use one-liner initializers.
-
Convenience initializer that creates a new
CALayer
from a local or remote URL. You must provide a completion block and add the passedSVGLayer to a sublayer
.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. You must add the passed
SVGLayer
to a sublayer to display it. -
Convenience initializer that creates a new
CALayer
from SVG data. You must provide a completion block and add the passedSVGLayer to a sublayer
.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. You must add the passed
SVGLayer
to a sublayer to display it.
-
Helper function that applies the given closure on all sublayers of a given type
Declaration
Swift
open func applyOnSublayers<T>(ofType: T.Type, closure: (T) -> ()) where T : CALayer
-
Helper function that returns an array of all sublayers of a given type
Declaration
Swift
public func sublayers<T, U>(in layer: T) -> [U] where T : CALayer