如何使用.svg探索SVGKit文件?
我有问题将一个.svg文件分割成几个UIView。
我试过的
以下是我迄今所做的工作。如果你对我该怎么做有任何线索,谢谢!
.svg文件。我给这两个物体中的一个取名"AAAA“。
.svg文件添加到我的项目中。SVGKit来浏览我的.svg文件,并使用以下代码:代码:
SVGKImage* newImage = [SVGKImage imageNamed:@"Untitled-1"];
NSString* tagToFind = @"AAAA";
NodeList* result = [newImage.DOMDocument getElementsByTagName:tagToFind];
for( Element* domElement in result )
{
SVGElement* svgElement = (SVGElement*) domElement;
}问题:
.svg图像加载良好,我可以显示它。这才是可行的!!但是..。newImage.DOMDocument似乎没有反映实际的文档。以下是NSLog给出的内容节点:#document (文档)值:(Null) @@0属性+0 x
result数组为空。备注
我用Illustrator创建了Illustrator,然后尝试添加关于Inkscape的信息。任何解决办法对我来说都是可以的。这是.png文件。
<?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>发布于 2014-05-28 18:02:37
正确的代码是
SVGKImage* newImage = [SVGKImage imageNamed:@"Untitled-1"];
NSString* tagToFind = @"BBBB";
Element* result = [newImage.DOMTree getElementById:tagToFind];https://stackoverflow.com/questions/23917935
复制相似问题