SVGKit导入
- 从github下载demo
-
打开"SVGKit-iOS.xcodeproj"
目录.png
- command + B 编译
- 找到"libSVGKit-iOS.2.x.x.a" 我这里是“libSVGKit-iOS.2.0.0.a” 在文件夹中显示

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

- 将下图所示的文件加入项目中(可以全部加入,也可根据需要选择)

- 在 Build Settings 中,"Other Linker Flags" 设置中添加 "-ObjC"
- 在 Build Phases 中,添加
CoreText
CoreImage
libxml2.dylib
QuartzCore
CoreGraphics
UIKit - 下图所示的位置添加"CocoaLumberjack.framework",

恭喜你 导入成功 可以使用了
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];
运行报错了 找了好久不知什么原因

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

SVGKit github地址 https://github.com/SVGKit/SVGKit
使用说明 http://t-machine.org/index.php/2012/12/31/svgkit-2013-usage/
其他的一些用法后面有空 后续更新
网友评论