ios - 如何在 iOS 中将 jpg 或 png 转换为 svg?

标签 ios objective-c svgkit

我喜欢将 .jpg 或 .png 文件转换为可以在 UIImageView 中显示的 .svg 格式。有没有办法在 Objective-C 中做到这一点?

最佳答案

shouldn't在 Xcode 中使用 SVG 图像:

it is recommended that you use PNG or JPEG files for most images in your app. Image objects are optimized for reading and displaying both formats, and those formats offer better performance than most other image formats. Because the PNG format is lossless, it is especially recommended for the images you use in your app’s interface.

此外,还有一个 SVGKit根据许多开发者的说法是 buggy所以使用它需要您自担风险。

SVG 是一种基于 XML 的矢量,在 Xcode 中您也可以使用矢量,但使用 PDF 格式并遵循 this教程。

简而言之:

  1. 使用@1x Assets 生成 PDF(在编译期间它将生成 @2 和 @3)
  2. 将比例因子设置为单个向量:

enter image description here

  1. 将您的 PDF 拖放到通用部分
  2. 通过名称引用您的图像,就像任何 PNG 文件一样

    [UIImage imageNamed:@”Home”]
    

此外,stackoverflow(可能)related回答

关于ios - 如何在 iOS 中将 jpg 或 png 转换为 svg?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39722740/

相关文章:

ios - 如何在 swift ios 中单击时更改单元格中的按钮?

ios - 计算路线后绘制的注释移动到用户的位置 - Skobbler

ios - 范围无效 :basic_info. 请改用 public_profile、user_friends

objective-c - 为什么使用cocoa库的HelloWorld代码无法构建?

ios - 如何将 SVGKit 放入我的项目中

ios - 无法再启动 React Native 0.15

java - 当我想要 NSNumber 的 intValue 时,如何防止自己意外使用它的指针?

objective-c - 具有多个日期条目的 Core Data 或 NSDictionary(每年大约 800 多个)?什么是最容易实现的?

ios - 如何获取 SVGElement 所属的组?

ios - 在启用 ARC 的项目中导入非 ARC 代码编译的 .a 文件