I have issues splitting one .svg
file into several UIView
.
Here is what I have done so far. If you have any clue on how I should proceed, thank you!
I created a .svg
file. I gave the name "AAAA" to one of the two objects.
I add the .svg
file to my project.
Then, I use SVGKit
to explore my .svg
file, with the following code:
code:
SVGKImage* newImage = [SVGKImage imageNamed:@"Untitled-1"];
NSString* tagToFind = @"AAAA";
NodeList* result = [newImage.DOMDocument getElementsByTagName:tagToFind];
for( Element* domElement in result )
{
SVGElement* svgElement = (SVGElement*) domElement;
}
The .svg
image is well loaded, and I can display it. This is what works!! But...
the newImage.DOMDocument
does not seem to reflect the actual document. Here is what NSLog
gives
Node: #document (DOCUMENT) value:[(null)] @@0 attributes + 0 x children
result
array is empty.I have created the .svg
with Illustrator
and then tried to add info on Inkscape
. Any solution is ok for me. Here is the .png
file.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="623.619px" height="481.89px" viewBox="0 0 623.619 481.89" enable-background="new 0 0 623.619 481.89"
xml:space="preserve">
<g id="AAAA" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://creativecommons.org/ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" sodipodi:docname="Untitled-1.svg" inkscape:version="0.48.2 r9819">
<rect id="AAAA_1_" x="482.945" y="43.653" fill="#FF0000" stroke="#000000" stroke-miterlimit="10" width="57.046" height="68.157"/>
</g>
<g id="BBBB_1_">
<polygon id="BBBB" fill="#2824B3" stroke="#000000" stroke-miterlimit="10" points="579.31,259.945 532.676,261.485
507.507,300.775 491.632,256.898 446.488,245.101 483.31,216.445 480.578,169.865 519.213,196.03 562.667,179.039 549.722,223.867
"/>
</g>
</svg>
The correct code is
SVGKImage* newImage = [SVGKImage imageNamed:@"Untitled-1"];
NSString* tagToFind = @"BBBB";
Element* result = [newImage.DOMTree getElementById:tagToFind];