如何在iPhone上呈现各种SVG文件? [英] How to render all kinds of SVG files on iPhone?

查看:636
本文介绍了如何在iPhone上呈现各种SVG文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在iPhone上渲染svg文件,我已经从GitHub下载了一个项目 SVGQuartzRenderer 但显示以下错误:

For rendering svg file on iPhone I have downloaded a project from GitHub SVGQuartzRenderer but it shows the following errors:

  1. UIKit/UIKit.h No such file or directory (我无法使用添加现有框架来添加它)
  2. Libxml/tree.h:No such file or directory
  3. Expected specifier-qualifier list before xmlParserCtxtPtr
  1. UIKit/UIKit.h No such file or directory (I am not able to add it using add existing frameworks)
  2. Libxml/tree.h:No such file or directory
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆