You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SDWebImageSVGCoder is a SVG coder plugin for [SDWebImage](https://github.com/rs/SDWebImage/) framework, which provide the image loading support for [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) using [SVGKit](https://github.com/SVGKit/SVGKit) SVG engine.
10
+
8
11
## Example
9
12
10
13
To run the example project, clone the repo, and run `pod install` from the Example directory first.
11
14
15
+
You can modify the code or use some other SVG files to check the compatibility.
16
+
12
17
## Requirements
13
18
19
+
+ iOS 8
20
+
14
21
## Installation
15
22
16
23
SDWebImageSVGCoder is available through [CocoaPods](https://cocoapods.org). To install
17
24
it, simply add the following line to your Podfile:
18
25
19
26
```ruby
20
27
pod 'SDWebImageSVGCoder'
28
+
pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '2.x'
21
29
```
22
30
31
+
**Note:** Because the dependency third party library [SVGKit](https://github.com/SVGKit/SVGKit#versions) does not release the 2.x version, and the current latest release version is not compatible for Xcode 9/10. So you should specify `2.x` branch dependency or using commit-id to import the dependency through CocoaPods.
32
+
23
33
## Usage
24
34
35
+
### Use UIImageView (render SVG as bitmap image)
36
+
25
37
To use SVG coder, you should firstly add the `SDImageSVGCoder` to the coders manager. Then you can call the View Category method to start load SVG images.
26
38
39
+
Because SVG is a [vector image](https://en.wikipedia.org/wiki/Vector_graphics) format, which means it does not have a fixed bitmap size. However, `UIImage` or `CGImage` are all [bitmap image](https://en.wikipedia.org/wiki/Raster_graphics). For `UIImageView`, we will only parse SVG with a fixed image size (from the SVG viewPort information). But we also support you to specify a desired size during image loading using `vectorImageSize` context option.
### Use SVGKImageView (render SVG as vector image)
65
+
66
+
[SVGKit](https://github.com/SVGKit/SVGKit) also provide some built-in image view class for vector image loading (scale to any size without losing detail). The `SVGKLayeredImageView` && `SVGKFastImageView` are the subclass of `SVGKImageView` base class. We supports these image view class as well. You can just use the same API like normal `UIImageView`.
67
+
68
+
For the documentation about `SVGKLayeredImageView`, `SVGKFastImageView` or `SVGKImageView`, check [SVGKit](https://github.com/SVGKit/SVGKit) repo for more information.
69
+
70
+
**Note**: If you only use these image view class and don't use SVG on `UIImageView`, you don't need to register the SVG coder to coders manager. These image view loading was using the [Custom Image Class](https://github.com/rs/SDWebImage/wiki/Advanced-Usage#customization) feature of SDWebImage.
71
+
72
+
**Attention**: These built-in image view class does not works well on `UIView.contentMode` property, you need to re-scale the layer tree after image was loaded. We provide a simple out-of-box solution to support it. Set the `sd_adjustContentMode` property to `YES` then all things done.
73
+
74
+
+ Objective-C
75
+
76
+
```objectivec
77
+
SVGKImageView *imageView; // can be either `SVGKLayeredImageView` or `SVGKFastImageView`
0 commit comments