UIView+WebCache.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "SDWebImageCompat.h"
  9. #if SD_UIKIT || SD_MAC
  10. #import "SDWebImageManager.h"
  11. typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable imageData);
  12. @interface UIView (WebCache)
  13. /**
  14. * Get the current image URL.
  15. *
  16. * Note that because of the limitations of categories this property can get out of sync
  17. * if you use setImage: directly.
  18. */
  19. - (nullable NSURL *)sd_imageURL;
  20. /**
  21. * Set the imageView `image` with an `url` and optionally a placeholder image.
  22. *
  23. * The download is asynchronous and cached.
  24. *
  25. * @param url The url for the image.
  26. * @param placeholder The image to be set initially, until the image request finishes.
  27. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  28. * @param operationKey A string to be used as the operation key. If nil, will use the class name
  29. * @param setImageBlock Block used for custom set image code
  30. * @param progressBlock A block called while image is downloading
  31. * @note the progress block is executed on a background queue
  32. * @param completedBlock A block called when operation has been completed. This block has no return value
  33. * and takes the requested UIImage as first parameter. In case of error the image parameter
  34. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  35. * indicating if the image was retrieved from the local cache or from the network.
  36. * The fourth parameter is the original image url.
  37. */
  38. - (void)sd_internalSetImageWithURL:(nullable NSURL *)url
  39. placeholderImage:(nullable UIImage *)placeholder
  40. options:(SDWebImageOptions)options
  41. operationKey:(nullable NSString *)operationKey
  42. setImageBlock:(nullable SDSetImageBlock)setImageBlock
  43. progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock
  44. completed:(nullable SDExternalCompletionBlock)completedBlock;
  45. /**
  46. * Cancel the current download
  47. */
  48. - (void)sd_cancelCurrentImageLoad;
  49. #if SD_UIKIT
  50. #pragma mark - Activity indicator
  51. /**
  52. * Show activity UIActivityIndicatorView
  53. */
  54. - (void)sd_setShowActivityIndicatorView:(BOOL)show;
  55. /**
  56. * set desired UIActivityIndicatorViewStyle
  57. *
  58. * @param style The style of the UIActivityIndicatorView
  59. */
  60. - (void)sd_setIndicatorStyle:(UIActivityIndicatorViewStyle)style;
  61. - (BOOL)sd_showActivityIndicatorView;
  62. - (void)sd_addActivityIndicator;
  63. - (void)sd_removeActivityIndicator;
  64. #endif
  65. @end
  66. #endif