ios - 如何使用 Macaw iOS 库从 url 显示 svg
问题描述
我需要在我的应用程序中显示 svg。svg 在服务器上可用,可以使用 url 访问。我正在尝试使用https://github.com/exyte/Macaw-Examples上提供的库。如何使用此库从 url 显示 svg。我也可以下载数据,但是库中没有将数据作为参数的方法?
解决方案
你需要这样使用SVGParser
:
class MyView: MacawView {
required init?(coder aDecoder: NSCoder) {
let url = ...
let text = try! String(contentsOfFile: file.path, encoding: String.Encoding.utf8)
let node = try! SVGParser.parse(text: text)
super.init(node: node, coder: aDecoder)
}
}
推荐阅读
- selenium - Firefox WebDriver 不会在 Flask 应用程序中启动
- html - 引导网格出错
- python - numpy 查找矩阵行中所有数字对组合的乘积
- arrays - 没有 AddressSanitizer 也能正常工作
- sql - Oracle Apex SQL 错误 Ora-00942:表或视图不存在
- linux - 将 WCF Web api 迁移到 asp.net 核心时客户端的更改
- powershell - Foreach-object Parallel 块中的错误处理 - Powershell 7
- java - 选择的 NavigationView 项目不起作用。如果我单击任何项目,则抽屉菜单正在关闭
- python - 使用 Python3 读取多行 CSV
- angular - 异步的角度自定义管道