MKAnnotationView+WebCache.m 2.1 KB

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