美文网首页
SVGKit使用

SVGKit使用

作者: ElevenXu | 来源:发表于2017-09-19 15:49 被阅读387次

SVGKit导入

  • 从github下载demo
  • 打开"SVGKit-iOS.xcodeproj"


    目录.png
  • command + B 编译
  • 找到"libSVGKit-iOS.2.x.x.a" 我这里是“libSVGKit-iOS.2.0.0.a” 在文件夹中显示
目标文件.png

前往上层文件夹 选择 Debug-universal / Release-universal 中的 libSVGKit-iOS.2.x.x.a文件 和 usr文件夹,拖入到你的项目中(如果想要 Debug文件,编译时需要在 Xcode-Edit Scheme 中选择 Debug;如果想要 Release文件,需要在 Xcode-Edit Scheme 中选择 Release)

目标文件.png
  • 将下图所示的文件加入项目中(可以全部加入,也可根据需要选择)
目标文件.png
  • 在 Build Settings 中,"Other Linker Flags" 设置中添加 "-ObjC"
  • 在 Build Phases 中,添加
    CoreText
    CoreImage
    libxml2.dylib
    QuartzCore
    CoreGraphics
    UIKit
  • 下图所示的位置添加"CocoaLumberjack.framework",
文件添加.png

恭喜你 导入成功 可以使用了

SVGKit使用

  • 导入头文件(#import "SVGKit.h" #import "SVGKImage.h" #import "SVGKParser.h")
 SVGKImage* newImage = [SVGKImage imageNamed:@"myImage.svg"];
 SVGKImageView* imageView = [[SVGKFastImageView alloc] initWithSVGKImage:newImage];
 [self.view addSubview:imageView];

运行报错了 找了好久不知什么原因

报错信息.png

调试了一下 发现是断言,但是并不知道为什么
于是我怀疑是我的svg资源文件有问题,到demo里弄了一个.svg格式的图片资源,发现成功了.

最后放张效果图和链接

效果图.png

SVGKit github地址 https://github.com/SVGKit/SVGKit
使用说明 http://t-machine.org/index.php/2012/12/31/svgkit-2013-usage/

其他的一些用法后面有空 后续更新

相关文章

网友评论

      本文标题:SVGKit使用

      本文链接:https://www.haomeiwen.com/subject/halwsxtx.html