mchoe / SwiftSVG

A simple, performant, and lightweight SVG parser
Other
1.93k stars 230 forks source link

Feature request: layer ID in SVGLayer #90

Closed pavelgubarev closed 6 years ago

pavelgubarev commented 6 years ago

Hi there!

I would like to be able to have 'id' property parsed from SVG into SVGLayer.

<path id="ground" fill="#748E25" stroke="#000000" stroke-width="3" stroke-miterlimit="10" d="M1041.5,1481

and then have something like

print(mySVGLayer.id) Maybe it is already done but I haven't found it.

Cheers!

mchoe commented 6 years ago

Hi @pavelgubarev, yes this feature is already available. For SVGShapeElements and SVGGroups (which includes <g> and the root <svg> elements), the id attribute sets the underlying SVGLayer's name property. This is the same as CALayer's name property and you can see the documentation for it here: https://developer.apple.com/documentation/quartzcore/calayer/1410879-name