【发布时间】:2011-10-23 16:55:03
【问题描述】:
这是上一篇关于在 UIWebview 中操作 SVG 的文章的延续。更多背景信息请先看这里:UIWebview manipulating SVG 'on the fly'
现在我正在尝试在同一框架内动态创建 SVG。
我曾尝试在 Javascript 中使用 createElementNS 方法,但没有成功。
这是我失败的尝试:
NSString *string = @"var svgDocument=document.getElementById('circle').getSVGDocument();var shape=svgDocument.createElementNS('http://www.w3.org/2000/svg', 'greencircle');shape.setAttributeNS(null, 'cx', 25);shape.setAttributeNS(null, 'cy', 25);shape.setAttributeNS(null, 'r', 20);shape.setAttributeNS(null, 'fill', 'green');svgDocument.appendChild(shape);";
[webView stringByEvaluatingJavaScriptFromString:string];
有人可以给我看一个例子,说明如何使用与上述类似的方法创建一个简单的圆圈。或者,如果有更好的方法来动态创建 SVG 图形,那么我很想知道!
谢谢。
【问题讨论】:
标签: iphone html ios uiwebview svg