Add WebCache category for NSButton on macOS
Showing
4 changed files
with
348 additions
and
0 deletions
@@ -37,6 +37,8 @@ | @@ -37,6 +37,8 @@ | ||
37 | 00733A711BC4880E00A5A117 /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 53922D95148C56230056699D /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 37 | 00733A711BC4880E00A5A117 /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 53922D95148C56230056699D /* UIImageView+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
38 | 00733A721BC4880E00A5A117 /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AB615301192DA24600A2D8E9 /* UIView+WebCacheOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 38 | 00733A721BC4880E00A5A117 /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AB615301192DA24600A2D8E9 /* UIView+WebCacheOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
39 | 00733A731BC4880E00A5A117 /* SDWebImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A2CAE031AB4BB5400B6BC39 /* SDWebImage.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 39 | 00733A731BC4880E00A5A117 /* SDWebImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A2CAE031AB4BB5400B6BC39 /* SDWebImage.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
40 | + 321DB3612011D4D70015D2CB /* NSButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 321DB35F2011D4D60015D2CB /* NSButton+WebCache.h */; settings = {ATTRIBUTES = (Public, ); }; }; | ||
41 | + 321DB3622011D4D70015D2CB /* NSButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 321DB3602011D4D60015D2CB /* NSButton+WebCache.m */; }; | ||
40 | 321E60861F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 42 | 321E60861F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
41 | 321E60871F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 43 | 321E60871F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
42 | 321E60881F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 44 | 321E60881F38E8C800405457 /* SDWebImageCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 321E60841F38E8C800405457 /* SDWebImageCoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
@@ -1285,6 +1287,8 @@ | @@ -1285,6 +1287,8 @@ | ||
1285 | 1287 | ||
1286 | /* Begin PBXFileReference section */ | 1288 | /* Begin PBXFileReference section */ |
1287 | 00733A4C1BC487C000A5A117 /* SDWebImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImage.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | 1289 | 00733A4C1BC487C000A5A117 /* SDWebImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImage.framework; sourceTree = BUILT_PRODUCTS_DIR; }; |
1290 | + 321DB35F2011D4D60015D2CB /* NSButton+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSButton+WebCache.h"; path = "SDWebImage/NSButton+WebCache.h"; sourceTree = "<group>"; }; | ||
1291 | + 321DB3602011D4D60015D2CB /* NSButton+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSButton+WebCache.m"; path = "SDWebImage/NSButton+WebCache.m"; sourceTree = "<group>"; }; | ||
1288 | 321E60841F38E8C800405457 /* SDWebImageCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageCoder.h; sourceTree = "<group>"; }; | 1292 | 321E60841F38E8C800405457 /* SDWebImageCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageCoder.h; sourceTree = "<group>"; }; |
1289 | 321E60851F38E8C800405457 /* SDWebImageCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCoder.m; sourceTree = "<group>"; }; | 1293 | 321E60851F38E8C800405457 /* SDWebImageCoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCoder.m; sourceTree = "<group>"; }; |
1290 | 321E60921F38E8ED00405457 /* SDWebImageImageIOCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageImageIOCoder.h; sourceTree = "<group>"; }; | 1294 | 321E60921F38E8ED00405457 /* SDWebImageImageIOCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageImageIOCoder.h; sourceTree = "<group>"; }; |
@@ -1640,6 +1644,8 @@ | @@ -1640,6 +1644,8 @@ | ||
1640 | children = ( | 1644 | children = ( |
1641 | 4397D2F41D0DE2DF00BB2784 /* NSImage+WebCache.h */, | 1645 | 4397D2F41D0DE2DF00BB2784 /* NSImage+WebCache.h */, |
1642 | 4397D2F51D0DE2DF00BB2784 /* NSImage+WebCache.m */, | 1646 | 4397D2F51D0DE2DF00BB2784 /* NSImage+WebCache.m */, |
1647 | + 321DB35F2011D4D60015D2CB /* NSButton+WebCache.h */, | ||
1648 | + 321DB3602011D4D60015D2CB /* NSButton+WebCache.m */, | ||
1643 | 535699B415113E7300A4C397 /* MKAnnotationView+WebCache.h */, | 1649 | 535699B415113E7300A4C397 /* MKAnnotationView+WebCache.h */, |
1644 | 535699B515113E7300A4C397 /* MKAnnotationView+WebCache.m */, | 1650 | 535699B515113E7300A4C397 /* MKAnnotationView+WebCache.m */, |
1645 | 53922D93148C56230056699D /* UIButton+WebCache.h */, | 1651 | 53922D93148C56230056699D /* UIButton+WebCache.h */, |
@@ -2295,6 +2301,7 @@ | @@ -2295,6 +2301,7 @@ | ||
2295 | 321E60B51F38E90100405457 /* SDWebImageWebPCoder.h in Headers */, | 2301 | 321E60B51F38E90100405457 /* SDWebImageWebPCoder.h in Headers */, |
2296 | 4397D2EB1D0DDD8C00BB2784 /* NSData+ImageContentType.h in Headers */, | 2302 | 4397D2EB1D0DDD8C00BB2784 /* NSData+ImageContentType.h in Headers */, |
2297 | 80377C851F2F666400F89830 /* huffman_encode_utils.h in Headers */, | 2303 | 80377C851F2F666400F89830 /* huffman_encode_utils.h in Headers */, |
2304 | + 321DB3612011D4D70015D2CB /* NSButton+WebCache.h in Headers */, | ||
2298 | 807A122D1F89636300EC2A9B /* SDWebImageCodersManager.h in Headers */, | 2305 | 807A122D1F89636300EC2A9B /* SDWebImageCodersManager.h in Headers */, |
2299 | 4397D2ED1D0DDD8C00BB2784 /* mux_types.h in Headers */, | 2306 | 4397D2ED1D0DDD8C00BB2784 /* mux_types.h in Headers */, |
2300 | 80377C831F2F666400F89830 /* filters_utils.h in Headers */, | 2307 | 80377C831F2F666400F89830 /* filters_utils.h in Headers */, |
@@ -3198,6 +3205,7 @@ | @@ -3198,6 +3205,7 @@ | ||
3198 | 80377C8C1F2F666400F89830 /* random_utils.c in Sources */, | 3205 | 80377C8C1F2F666400F89830 /* random_utils.c in Sources */, |
3199 | 323F8BAD1F38EF770092B609 /* picture_psnr_enc.c in Sources */, | 3206 | 323F8BAD1F38EF770092B609 /* picture_psnr_enc.c in Sources */, |
3200 | 323F8BC51F38EF770092B609 /* quant_enc.c in Sources */, | 3207 | 323F8BC51F38EF770092B609 /* quant_enc.c in Sources */, |
3208 | + 321DB3622011D4D70015D2CB /* NSButton+WebCache.m in Sources */, | ||
3201 | 80377C7F1F2F666400F89830 /* color_cache_utils.c in Sources */, | 3209 | 80377C7F1F2F666400F89830 /* color_cache_utils.c in Sources */, |
3202 | 80377E331F2F66A800F89830 /* alpha_processing_neon.c in Sources */, | 3210 | 80377E331F2F66A800F89830 /* alpha_processing_neon.c in Sources */, |
3203 | 80377E401F2F66A800F89830 /* dec_clip_tables.c in Sources */, | 3211 | 80377E401F2F66A800F89830 /* dec_clip_tables.c in Sources */, |
SDWebImage/NSButton+WebCache.h
0 → 100644
1 | +/* | ||
2 | + * This file is part of the SDWebImage package. | ||
3 | + * (c) Olivier Poitrey <rs@dailymotion.com> | ||
4 | + * | ||
5 | + * For the full copyright and license information, please view the LICENSE | ||
6 | + * file that was distributed with this source code. | ||
7 | + */ | ||
8 | + | ||
9 | +#import "SDWebImageCompat.h" | ||
10 | + | ||
11 | +#if SD_MAC | ||
12 | + | ||
13 | +#import "SDWebImageManager.h" | ||
14 | + | ||
15 | +@interface NSButton (WebCache) | ||
16 | + | ||
17 | +#pragma mark - Image | ||
18 | + | ||
19 | +/** | ||
20 | + * Set the button `image` with an `url`. | ||
21 | + * | ||
22 | + * The download is asynchronous and cached. | ||
23 | + * | ||
24 | + * @param url The url for the image. | ||
25 | + */ | ||
26 | +- (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; | ||
27 | + | ||
28 | +/** | ||
29 | + * Set the button `image` with an `url` and a placeholder. | ||
30 | + * | ||
31 | + * The download is asynchronous and cached. | ||
32 | + * | ||
33 | + * @param url The url for the image. | ||
34 | + * @param placeholder The image to be set initially, until the image request finishes. | ||
35 | + * @see sd_setImageWithURL:placeholderImage:options: | ||
36 | + */ | ||
37 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
38 | + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; | ||
39 | + | ||
40 | +/** | ||
41 | + * Set the button `image` with an `url`, placeholder and custom options. | ||
42 | + * | ||
43 | + * The download is asynchronous and cached. | ||
44 | + * | ||
45 | + * @param url The url for the image. | ||
46 | + * @param placeholder The image to be set initially, until the image request finishes. | ||
47 | + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. | ||
48 | + */ | ||
49 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
50 | + placeholderImage:(nullable UIImage *)placeholder | ||
51 | + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; | ||
52 | + | ||
53 | +/** | ||
54 | + * Set the button `image` with an `url`. | ||
55 | + * | ||
56 | + * The download is asynchronous and cached. | ||
57 | + * | ||
58 | + * @param url The url for the image. | ||
59 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
60 | + * and takes the requested UIImage as first parameter. In case of error the image parameter | ||
61 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
62 | + * indicating if the image was retrieved from the local cache or from the network. | ||
63 | + * The fourth parameter is the original image url. | ||
64 | + */ | ||
65 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
66 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
67 | + | ||
68 | +/** | ||
69 | + * Set the button `image` with an `url`, placeholder. | ||
70 | + * | ||
71 | + * The download is asynchronous and cached. | ||
72 | + * | ||
73 | + * @param url The url for the image. | ||
74 | + * @param placeholder The image to be set initially, until the image request finishes. | ||
75 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
76 | + * and takes the requested UIImage as first parameter. In case of error the image parameter | ||
77 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
78 | + * indicating if the image was retrieved from the local cache or from the network. | ||
79 | + * The fourth parameter is the original image url. | ||
80 | + */ | ||
81 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
82 | + placeholderImage:(nullable UIImage *)placeholder | ||
83 | + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; | ||
84 | + | ||
85 | +/** | ||
86 | + * Set the button `image` with an `url`, placeholder and custom options. | ||
87 | + * | ||
88 | + * The download is asynchronous and cached. | ||
89 | + * | ||
90 | + * @param url The url for the image. | ||
91 | + * @param placeholder The image to be set initially, until the image request finishes. | ||
92 | + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. | ||
93 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
94 | + * and takes the requested UIImage as first parameter. In case of error the image parameter | ||
95 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
96 | + * indicating if the image was retrieved from the local cache or from the network. | ||
97 | + * The fourth parameter is the original image url. | ||
98 | + */ | ||
99 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
100 | + placeholderImage:(nullable UIImage *)placeholder | ||
101 | + options:(SDWebImageOptions)options | ||
102 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
103 | + | ||
104 | +/** | ||
105 | + * Set the button `image` with an `url`, placeholder and custom options. | ||
106 | + * | ||
107 | + * The download is asynchronous and cached. | ||
108 | + * | ||
109 | + * @param url The url for the image. | ||
110 | + * @param placeholder The image to be set initially, until the image request finishes. | ||
111 | + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. | ||
112 | + * @param progressBlock A block called while image is downloading | ||
113 | + * @note the progress block is executed on a background queue | ||
114 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
115 | + * and takes the requested UIImage as first parameter. In case of error the image parameter | ||
116 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
117 | + * indicating if the image was retrieved from the local cache or from the network. | ||
118 | + * The fourth parameter is the original image url. | ||
119 | + */ | ||
120 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
121 | + placeholderImage:(nullable UIImage *)placeholder | ||
122 | + options:(SDWebImageOptions)options | ||
123 | + progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock | ||
124 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
125 | + | ||
126 | +#pragma mark - Alternate Image | ||
127 | + | ||
128 | +/** | ||
129 | + * Set the button `alternateImage` with an `url`. | ||
130 | + * | ||
131 | + * The download is asynchronous and cached. | ||
132 | + * | ||
133 | + * @param url The url for the alternateImage. | ||
134 | + */ | ||
135 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; | ||
136 | + | ||
137 | +/** | ||
138 | + * Set the button `alternateImage` with an `url` and a placeholder. | ||
139 | + * | ||
140 | + * The download is asynchronous and cached. | ||
141 | + * | ||
142 | + * @param url The url for the alternateImage. | ||
143 | + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. | ||
144 | + * @see sd_setAlternateImageWithURL:placeholderImage:options: | ||
145 | + */ | ||
146 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
147 | + placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT; | ||
148 | + | ||
149 | +/** | ||
150 | + * Set the button `alternateImage` with an `url`, placeholder and custom options. | ||
151 | + * | ||
152 | + * The download is asynchronous and cached. | ||
153 | + * | ||
154 | + * @param url The url for the alternateImage. | ||
155 | + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. | ||
156 | + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. | ||
157 | + */ | ||
158 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
159 | + placeholderImage:(nullable UIImage *)placeholder | ||
160 | + options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT; | ||
161 | + | ||
162 | +/** | ||
163 | + * Set the button `alternateImage` with an `url`. | ||
164 | + * | ||
165 | + * The download is asynchronous and cached. | ||
166 | + * | ||
167 | + * @param url The url for the alternateImage. | ||
168 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
169 | + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter | ||
170 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
171 | + * indicating if the alternateImage was retrieved from the local cache or from the network. | ||
172 | + * The fourth parameter is the original alternateImage url. | ||
173 | + */ | ||
174 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
175 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
176 | + | ||
177 | +/** | ||
178 | + * Set the button `alternateImage` with an `url`, placeholder. | ||
179 | + * | ||
180 | + * The download is asynchronous and cached. | ||
181 | + * | ||
182 | + * @param url The url for the alternateImage. | ||
183 | + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. | ||
184 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
185 | + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter | ||
186 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
187 | + * indicating if the alternateImage was retrieved from the local cache or from the network. | ||
188 | + * The fourth parameter is the original alternateImage url. | ||
189 | + */ | ||
190 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
191 | + placeholderImage:(nullable UIImage *)placeholder | ||
192 | + completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT; | ||
193 | + | ||
194 | +/** | ||
195 | + * Set the button `alternateImage` with an `url`, placeholder and custom options. | ||
196 | + * | ||
197 | + * The download is asynchronous and cached. | ||
198 | + * | ||
199 | + * @param url The url for the alternateImage. | ||
200 | + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. | ||
201 | + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. | ||
202 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
203 | + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter | ||
204 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
205 | + * indicating if the alternateImage was retrieved from the local cache or from the network. | ||
206 | + * The fourth parameter is the original alternateImage url. | ||
207 | + */ | ||
208 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
209 | + placeholderImage:(nullable UIImage *)placeholder | ||
210 | + options:(SDWebImageOptions)options | ||
211 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
212 | + | ||
213 | +/** | ||
214 | + * Set the button `alternateImage` with an `url`, placeholder and custom options. | ||
215 | + * | ||
216 | + * The download is asynchronous and cached. | ||
217 | + * | ||
218 | + * @param url The url for the alternateImage. | ||
219 | + * @param placeholder The alternateImage to be set initially, until the alternateImage request finishes. | ||
220 | + * @param options The options to use when downloading the alternateImage. @see SDWebImageOptions for the possible values. | ||
221 | + * @param progressBlock A block called while alternateImage is downloading | ||
222 | + * @note the progress block is executed on a background queue | ||
223 | + * @param completedBlock A block called when operation has been completed. This block has no return value | ||
224 | + * and takes the requested UIImage as first parameter. In case of error the alternateImage parameter | ||
225 | + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean | ||
226 | + * indicating if the alternateImage was retrieved from the local cache or from the network. | ||
227 | + * The fourth parameter is the original alternateImage url. | ||
228 | + */ | ||
229 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
230 | + placeholderImage:(nullable UIImage *)placeholder | ||
231 | + options:(SDWebImageOptions)options | ||
232 | + progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock | ||
233 | + completed:(nullable SDExternalCompletionBlock)completedBlock; | ||
234 | + | ||
235 | +@end | ||
236 | + | ||
237 | +#endif |
SDWebImage/NSButton+WebCache.m
0 → 100644
1 | +/* | ||
2 | + * This file is part of the SDWebImage package. | ||
3 | + * (c) Olivier Poitrey <rs@dailymotion.com> | ||
4 | + * | ||
5 | + * For the full copyright and license information, please view the LICENSE | ||
6 | + * file that was distributed with this source code. | ||
7 | + */ | ||
8 | + | ||
9 | +#import "NSButton+WebCache.h" | ||
10 | + | ||
11 | +#if SD_MAC | ||
12 | + | ||
13 | +#import "UIView+WebCache.h" | ||
14 | + | ||
15 | +@implementation NSButton (WebCache) | ||
16 | + | ||
17 | +#pragma mark - Image | ||
18 | + | ||
19 | +- (void)sd_setImageWithURL:(nullable NSURL *)url { | ||
20 | + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; | ||
21 | +} | ||
22 | + | ||
23 | +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { | ||
24 | + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; | ||
25 | +} | ||
26 | + | ||
27 | +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { | ||
28 | + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; | ||
29 | +} | ||
30 | + | ||
31 | +- (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
32 | + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; | ||
33 | +} | ||
34 | + | ||
35 | +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
36 | + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; | ||
37 | +} | ||
38 | + | ||
39 | +- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
40 | + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; | ||
41 | +} | ||
42 | + | ||
43 | +- (void)sd_setImageWithURL:(nullable NSURL *)url | ||
44 | + placeholderImage:(nullable UIImage *)placeholder | ||
45 | + options:(SDWebImageOptions)options | ||
46 | + progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock | ||
47 | + completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
48 | + [self sd_internalSetImageWithURL:url | ||
49 | + placeholderImage:placeholder | ||
50 | + options:options | ||
51 | + operationKey:nil | ||
52 | + setImageBlock:nil | ||
53 | + progress:progressBlock | ||
54 | + completed:completedBlock]; | ||
55 | +} | ||
56 | + | ||
57 | +#pragma mark - Alternate Image | ||
58 | + | ||
59 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url { | ||
60 | + [self sd_setAlternateImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; | ||
61 | +} | ||
62 | + | ||
63 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder { | ||
64 | + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; | ||
65 | +} | ||
66 | + | ||
67 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options { | ||
68 | + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; | ||
69 | +} | ||
70 | + | ||
71 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
72 | + [self sd_setAlternateImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; | ||
73 | +} | ||
74 | + | ||
75 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
76 | + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; | ||
77 | +} | ||
78 | + | ||
79 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
80 | + [self sd_setAlternateImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; | ||
81 | +} | ||
82 | + | ||
83 | +- (void)sd_setAlternateImageWithURL:(nullable NSURL *)url | ||
84 | + placeholderImage:(nullable UIImage *)placeholder | ||
85 | + options:(SDWebImageOptions)options | ||
86 | + progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock | ||
87 | + completed:(nullable SDExternalCompletionBlock)completedBlock { | ||
88 | + __weak typeof(self)weakSelf = self; | ||
89 | + [self sd_internalSetImageWithURL:url | ||
90 | + placeholderImage:placeholder | ||
91 | + options:options | ||
92 | + operationKey:nil | ||
93 | + setImageBlock:^(NSImage * _Nullable image, NSData * _Nullable imageData) { | ||
94 | + weakSelf.alternateImage = image; | ||
95 | + } | ||
96 | + progress:progressBlock | ||
97 | + completed:completedBlock]; | ||
98 | +} | ||
99 | + | ||
100 | +@end | ||
101 | + | ||
102 | +#endif |
@@ -54,6 +54,7 @@ FOUNDATION_EXPORT const unsigned char WebImageVersionString[]; | @@ -54,6 +54,7 @@ FOUNDATION_EXPORT const unsigned char WebImageVersionString[]; | ||
54 | 54 | ||
55 | #if SD_MAC | 55 | #if SD_MAC |
56 | #import <SDWebImage/NSImage+WebCache.h> | 56 | #import <SDWebImage/NSImage+WebCache.h> |
57 | + #import <SDWebImage/NSButton+WebCache.h> | ||
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | #if SD_UIKIT | 60 | #if SD_UIKIT |
-
Please register or login to post a comment