Skip to content

Commit 9393445

Browse files
committed
Rename vectorImageSize context option to SVGImageSize, which make it clear for SVG spec. (We'll add other vector image format like PDF, so the naming should related to their context)
1 parent 94aa1e6 commit 9393445

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

Example/SDWebImageSVGCoder/SDViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ - (void)viewDidLoad
5858
}
5959
}];
6060
// For `UIImageView`, you can specify a desired SVG size instead of original SVG viewport (which may be small)
61-
[imageView3 sd_setImageWithURL:svgURL3 placeholderImage:nil options:SDWebImageRetryFailed context:@{SDWebImageContextVectorImageSize : @(CGSizeMake(100, 100))} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
61+
[imageView3 sd_setImageWithURL:svgURL3 placeholderImage:nil options:SDWebImageRetryFailed context:@{SDWebImageContextSVGImageSize : @(CGSizeMake(100, 100))} progress:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
6262
if (image) {
6363
NSLog(@"UIImageView SVG load success");
6464
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ github "SVGKit/SVGKit" "2.x"
5353

5454
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.
5555

56-
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.
56+
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 `SVGImageSize` context option.
5757

5858
+ Objective-C
5959

@@ -62,8 +62,8 @@ SDImageSVGCoder *SVGCoder = [SDImageSVGCoder sharedCoder];
6262
[[SDImageCodersManager sharedManager] addCoder:SVGCoder];
6363
UIImageView *imageView;
6464
// this arg is optional, if don't provide, use the viewport size instead
65-
CGSize vectorImageSize = CGSizeMake(100, 100);
66-
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextVectorImageSize : @(vectorImageSize)];
65+
CGSize SVGImageSize = CGSizeMake(100, 100);
66+
[imageView sd_setImageWithURL:url placeholderImage:nil options:0 context:@{SDWebImageContextSVGImageSize : @(SVGImageSize)];
6767
```
6868
6969
+ Swift
@@ -74,8 +74,8 @@ SDImageCodersManager.shared.addCoder(SVGCoder)
7474
let imageView: UIImageView
7575
imageView.sd_setImage(with: url)
7676
// this arg is optional, if don't provide, use the viewport size instead
77-
let vectorImageSize = CGSize(width: 100, height: 100)
78-
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.vectorImageSize : vectorImageSize])
77+
let SVGImageSize = CGSize(width: 100, height: 100)
78+
imageView.sd_setImage(with: url, placeholderImage: nil, options: [], context: [.svgImageSize : SVGImageSize])
7979
```
8080

8181
### Use SVGKImageView (render SVG as vector image)

SDWebImageSVGCoder/Classes/SDImageSVGCoder.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ - (UIImage *)decodedImageWithData:(NSData *)data options:(SDImageCoderOptions *)
4040

4141
// Check specified image size
4242
SDWebImageContext *context = options[SDImageCoderWebImageContext];
43-
if (context[SDWebImageContextVectorImageSize]) {
44-
NSValue *sizeValue = context[SDWebImageContextVectorImageSize];
43+
if (context[SDWebImageContextSVGImageSize]) {
44+
NSValue *sizeValue = context[SDWebImageContextSVGImageSize];
4545
#if SD_UIKIT
4646
CGSize imageSize = sizeValue.CGSizeValue;
4747
#else

SDWebImageSVGCoder/Classes/SDSVGImage.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ - (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale options:(SDImag
6363
}
6464
// Check specified image size
6565
SDWebImageContext *context = options[SDImageCoderWebImageContext];
66-
if (context[SDWebImageContextVectorImageSize]) {
67-
NSValue *sizeValue = context[SDWebImageContextVectorImageSize];
66+
if (context[SDWebImageContextSVGImageSize]) {
67+
NSValue *sizeValue = context[SDWebImageContextSVGImageSize];
6868
#if SD_UIKIT
6969
CGSize imageSize = sizeValue.CGSizeValue;
7070
#else

SDWebImageSVGCoder/Classes/SDWebImageSVGCoderDefine.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ FOUNDATION_EXPORT void SDAdjustSVGContentMode(SVGKImage * __nonnull svgImage, UI
2222
#endif
2323

2424
/**
25-
A CGSize raw value which specify the desired vector image size during image loading. Because vector image like SVG format, may not contains a fixed size, or you want to get a larger size bitmap representation UIImage. (NSValue)
25+
A CGSize raw value which specify the desired SVG image size during image loading. Because vector image like SVG format, may not contains a fixed size, or you want to get a larger size bitmap representation UIImage. (NSValue)
2626
*/
27-
FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextVectorImageSize;
27+
FOUNDATION_EXPORT SDWebImageContextOption _Nonnull const SDWebImageContextSVGImageSize;

SDWebImageSVGCoder/Classes/SDWebImageSVGCoderDefine.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ void SDAdjustSVGContentMode(SVGKImage * svgImage, UIViewContentMode contentMode,
140140
}
141141
#endif
142142

143-
SDWebImageContextOption _Nonnull const SDWebImageContextVectorImageSize = @"vectorImageSize";
143+
SDWebImageContextOption _Nonnull const SDWebImageContextSVGImageSize = @"svgImageSize";

0 commit comments

Comments
 (0)