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

查看:22
本文介绍了如何在 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 没有那个文件或目录(我无法使用添加现有框架来添加它)
  2. Libxml/tree.h:没有那个文件或目录
  3. 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,您可以在 Assets Catalog 中添加 .svg 文件并执行以下操作:

Starting Xcode 12, you can add the .svg file in your Assets Catalog and do this:

let image = UIImage(named: "SomeSVGImage")

参考:https://developer.apple.com/documentation/xcode-release-notes/xcode-12-beta-release-notes

这篇关于如何在 iPhone 上渲染各种 SVG 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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