UIImageView+WebCache.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #import "UIImageView+WebCache.h"
  9. #import "objc/runtime.h"
  10. #import "UIView+WebCacheOperation.h"
  11. #import "UIView+WebCache.h"
  12. @implementation UIImageView (WebCache)
  13. - (void)sd_setImageWithURL:(nullable NSURL *)url {
  14. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
  15. }
  16. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder {
  17. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil];
  18. }
  19. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options {
  20. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil];
  21. }
  22. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context {
  23. [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:context progress:nil completed:nil];
  24. }
  25. - (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock {
  26. [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock];
  27. }
  28. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock {
  29. [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock];
  30. }
  31. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock {
  32. [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock];
  33. }
  34. - (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDImageLoaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock {
  35. [self sd_setImageWithURL:url placeholderImage:placeholder options:options context:nil progress:progressBlock completed:completedBlock];
  36. }
  37. - (void)sd_setImageWithURL:(nullable NSURL *)url
  38. placeholderImage:(nullable UIImage *)placeholder
  39. options:(SDWebImageOptions)options
  40. context:(nullable SDWebImageContext *)context
  41. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  42. completed:(nullable SDExternalCompletionBlock)completedBlock {
  43. [self sd_internalSetImageWithURL:url
  44. placeholderImage:placeholder
  45. options:options
  46. context:context
  47. setImageBlock:nil
  48. progress:progressBlock
  49. completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
  50. if (completedBlock) {
  51. completedBlock(image, error, cacheType, imageURL);
  52. }
  53. }];
  54. }
  55. - (void)sd_cancelCurrentAnimationImagesLoad {
  56. [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"];
  57. }
  58. @end