【问题标题】:How To decode Base64 encoded .SVG string using Swift 5.x如何使用 Swift 5.x 解码 Base64 编码的 .SVG 字符串
【发布时间】:2022-12-05 22:01:43
【问题描述】:

我想使用 Swift 5.x 解码 base64 编码的 .svg 图像。谁能指导我如何去做?

我之前已经对 base64 .png 进行了编码和解码。具体需要有关 .svg 的帮助。

【问题讨论】:

  • 为什么 svg 与 png 不同?有什么问题?您是否有一些代码在 SVG 上不起作用但在 png 上起作用?

标签: ios swift svg base64 decoding


【解决方案1】:
  pod 'SVGKit'

安装这个 pod 然后设置这个代码真的帮助我解决了我的问题

 let temp = qrCode.components(separatedBy: ",")
 let dataDecoded : Data = Data(base64Encoded: temp[1], options:
                         .ignoreUnknownCharacters)!

  let decoded = SVGKImage(data:dataDecoded)
    self.youriimage.image = decoded?.uiImage

【讨论】:

    猜你喜欢
    • 2011-10-31
    • 2021-10-27
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多