UIImageView+HighlightedWebCache.m 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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+HighlightedWebCache.h"
  9. #if SD_UIKIT
  10. #import "UIView+WebCacheOperation.h"
  11. #import "UIView+WebCache.h"
  12. @implementation UIImageView (HighlightedWebCache)
  13. - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url {
  14. [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil];
  15. }
  16. - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options {
  17. [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil];
  18. }
  19. - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock {
  20. [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock];
  21. }
  22. - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock {
  23. [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock];
  24. }
  25. - (void)sd_setHighlightedImageWithURL:(nullable NSURL *)url
  26. options:(SDWebImageOptions)options
  27. progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
  28. completed:(nullable SDExternalCompletionBlock)completedBlock {
  29. __weak typeof(self)weakSelf = self;
  30. [self sd_internalSetImageWithURL:url
  31. placeholderImage:nil
  32. options:options
  33. operationKey:@"UIImageViewImageOperationHighlighted"
  34. setImageBlock:^(UIImage *image, NSData *imageData) {
  35. weakSelf.highlightedImage = image;
  36. }
  37. progress:progressBlock
  38. completed:completedBlock];
  39. }
  40. @end
  41. #endif