如何在iPhone上呈现各种SVG文件? [英] How to render all kinds of SVG files on iPhone?
问题描述
要在iPhone上渲染svg文件,我已经从GitHub下载了一个项目 SVGQuartzRenderer 但显示以下错误:
For rendering svg file on iPhone I have downloaded a project from GitHub SVGQuartzRenderer but it shows the following errors:
-
UIKit/UIKit.h No such file or directory
(我无法使用添加现有框架来添加它) -
Libxml/tree.h:No such file or directory
-
Expected specifier-qualifier list before xmlParserCtxtPtr
UIKit/UIKit.h No such file or directory
(I am not able to add it using add existing frameworks)Libxml/tree.h:No such file or directory
Expected specifier-qualifier list before xmlParserCtxtPtr
有人知道我如何使该项目正常工作吗?
Does anyone know how I can make this project work?
我还找到了另一个框架: SVGKit . 它适用于某些SVG文件,但不适用于所有文件.
I have also found another framework: SVGKit. It works well for some SVG files but not for all.
是否可以在不使用UIWebView
的情况下在iPhone中渲染任何SVG文件,并且是否有任何教程或示例代码?
Is it possible to render any SVG file in iPhone without using UIWebView
and are there any tutorials or sample code?
推荐答案
从Xcode 12开始,您可以在资产目录中添加.svg文件,并执行以下操作:
Starting Xcode 12, you can add the .svg file in your Assets Catalog and do this:
let image = UIImage(named: "SomeSVGImage")
ref: https://developer .apple.com/documentation/xcode-release-notes/xcode-12-beta-release-notes
这篇关于如何在iPhone上呈现各种SVG文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!