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 path d 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 bundle

    let view = UIView(SVGNamed: "hawaiiFlowers")
    

    Declaration

    Swift

    public convenience init(SVGNamed: String, parser: SVGParser? = nil, completion: ((SVGLayer) -> ())? = nil)

    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 URL

    Upon 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

    Swift

    public convenience init(SVGURL: URL, parser: SVGParser? = nil, completion: ((SVGLayer) -> ())? = nil)

    Parameters

    SVGURL

    The local or remote URL of the SVG resource

    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 with the given SVG data

    Upon completion, it will resize the layer to aspect fit this view’s superview

    let view = UIView(SVGData: svgData)
    

    Declaration

    Swift

    public convenience init(SVGData svgData: Data, parser: SVGParser? = nil, completion: ((SVGLayer) -> ())? = nil)

    Parameters

    SVGData

    The SVG Data to be parsed

    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