SVGKImageView+WebCache.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. //
  2. // SVGKImageView+WebCache.h
  3. // SDWebImageSVGPlugin
  4. //
  5. // Created by DreamPiggy on 2018/10/10.
  6. //
  7. #import <SVGKit/SVGKit.h>
  8. #import "SDWebImageSVGKitDefine.h"
  9. NS_ASSUME_NONNULL_BEGIN
  10. @interface SVGKImageView (WebCache)
  11. /**
  12. * Unlike `UIView`, `SVGKImageView`'s subclass does not follows `UIView.contentMode` property, the position of SVG vector image is controled by `SVGKImage` instance with SVG's viewport && viewbox information. You can adjust it after image was loading, however it's not so convenient.
  13. * So we provide a simple solution. If you want the same behavior like UIImageView to use `contentMode` property to position SVG images, set this value to YES and we'll resize the SVG image to correspond `contentMode` of `SVGKImageView` during image loading.
  14. */
  15. @property (nonatomic, assign) BOOL sd_adjustContentMode API_UNAVAILABLE(macos);
  16. /**
  17. * Set the imageView `image` with an `url`.
  18. *
  19. * The download is asynchronous and cached.
  20. *
  21. * @param url The url for the image.
  22. */
  23. - (void)sd_setImageWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT;
  24. /**
  25. * Set the imageView `image` with an `url` and a placeholder.
  26. *
  27. * The download is asynchronous and cached.
  28. *
  29. * @param url The url for the image.
  30. * @param placeholder The image to be set initially, until the image request finishes.
  31. * @see sd_setImageWithURL:placeholderImage:options:
  32. */
  33. - (void)sd_setImageWithURL:(nullable NSURL *)url
  34. placeholderImage:(nullable UIImage *)placeholder NS_REFINED_FOR_SWIFT;
  35. /**
  36. * Set the imageView `image` with an `url`, placeholder and custom options.
  37. *
  38. * The download is asynchronous and cached.
  39. *
  40. * @param url The url for the image.
  41. * @param placeholder The image to be set initially, until the image request finishes.
  42. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  43. */
  44. - (void)sd_setImageWithURL:(nullable NSURL *)url
  45. placeholderImage:(nullable UIImage *)placeholder
  46. options:(SDWebImageOptions)options NS_REFINED_FOR_SWIFT;
  47. /**
  48. * Set the imageView `image` with an `url`, placeholder, custom options and context.
  49. *
  50. * The download is asynchronous and cached.
  51. *
  52. * @param url The url for the image.
  53. * @param placeholder The image to be set initially, until the image request finishes.
  54. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  55. * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
  56. */
  57. - (void)sd_setImageWithURL:(nullable NSURL *)url
  58. placeholderImage:(nullable UIImage *)placeholder
  59. options:(SDWebImageOptions)options
  60. context:(nullable SDWebImageContext *)context;
  61. /**
  62. * Set the imageView `image` with an `url`.
  63. *
  64. * The download is asynchronous and cached.
  65. *
  66. * @param url The url for the image.
  67. * @param completedBlock A block called when operation has been completed. This block has no return value
  68. * and takes the requested UIImage as first parameter. In case of error the image parameter
  69. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  70. * indicating if the image was retrieved from the local cache or from the network.
  71. * The fourth parameter is the original image url.
  72. */
  73. - (void)sd_setImageWithURL:(nullable NSURL *)url
  74. completed:(nullable SDExternalCompletionBlock)completedBlock;
  75. /**
  76. * Set the imageView `image` with an `url`, placeholder.
  77. *
  78. * The download is asynchronous and cached.
  79. *
  80. * @param url The url for the image.
  81. * @param placeholder The image to be set initially, until the image request finishes.
  82. * @param completedBlock A block called when operation has been completed. This block has no return value
  83. * and takes the requested UIImage as first parameter. In case of error the image parameter
  84. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  85. * indicating if the image was retrieved from the local cache or from the network.
  86. * The fourth parameter is the original image url.
  87. */
  88. - (void)sd_setImageWithURL:(nullable NSURL *)url
  89. placeholderImage:(nullable UIImage *)placeholder
  90. completed:(nullable SDExternalCompletionBlock)completedBlock NS_REFINED_FOR_SWIFT;
  91. /**
  92. * Set the imageView `image` with an `url`, placeholder and custom options.
  93. *
  94. * The download is asynchronous and cached.
  95. *
  96. * @param url The url for the image.
  97. * @param placeholder The image to be set initially, until the image request finishes.
  98. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  99. * @param completedBlock A block called when operation has been completed. This block has no return value
  100. * and takes the requested UIImage as first parameter. In case of error the image parameter
  101. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  102. * indicating if the image was retrieved from the local cache or from the network.
  103. * The fourth parameter is the original image url.
  104. */
  105. - (void)sd_setImageWithURL:(nullable NSURL *)url
  106. placeholderImage:(nullable UIImage *)placeholder
  107. options:(SDWebImageOptions)options
  108. completed:(nullable SDExternalCompletionBlock)completedBlock;
  109. /**
  110. * Set the imageView `image` with an `url`, placeholder and custom options.
  111. *
  112. * The download is asynchronous and cached.
  113. *
  114. * @param url The url for the image.
  115. * @param placeholder The image to be set initially, until the image request finishes.
  116. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  117. * @param progressBlock A block called while image is downloading
  118. * @note the progress block is executed on a background queue
  119. * @param completedBlock A block called when operation has been completed. This block has no return value
  120. * and takes the requested UIImage as first parameter. In case of error the image parameter
  121. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  122. * indicating if the image was retrieved from the local cache or from the network.
  123. * The fourth parameter is the original image url.
  124. */
  125. - (void)sd_setImageWithURL:(nullable NSURL *)url
  126. placeholderImage:(nullable UIImage *)placeholder
  127. options:(SDWebImageOptions)options
  128. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  129. completed:(nullable SDExternalCompletionBlock)completedBlock;
  130. /**
  131. * Set the imageView `image` with an `url`, placeholder, custom options and context.
  132. *
  133. * The download is asynchronous and cached.
  134. *
  135. * @param url The url for the image.
  136. * @param placeholder The image to be set initially, until the image request finishes.
  137. * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values.
  138. * @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
  139. * @param progressBlock A block called while image is downloading
  140. * @note the progress block is executed on a background queue
  141. * @param completedBlock A block called when operation has been completed. This block has no return value
  142. * and takes the requested UIImage as first parameter. In case of error the image parameter
  143. * is nil and the second parameter may contain an NSError. The third parameter is a Boolean
  144. * indicating if the image was retrieved from the local cache or from the network.
  145. * The fourth parameter is the original image url.
  146. */
  147. - (void)sd_setImageWithURL:(nullable NSURL *)url
  148. placeholderImage:(nullable UIImage *)placeholder
  149. options:(SDWebImageOptions)options
  150. context:(nullable SDWebImageContext *)context
  151. progress:(nullable SDImageLoaderProgressBlock)progressBlock
  152. completed:(nullable SDExternalCompletionBlock)completedBlock;
  153. @end
  154. NS_ASSUME_NONNULL_END