抽茧剥丝系列-Kingfisher

  • 因为涉及到UI的改变,所以要在主线程调用该function
1
2
3
4
5
6
7
8
9
public func setImage(
with source: Source?,
placeholder: Placeholder? = nil,
options: KingfisherOptionsInfo? = nil,
progressBlock: DownloadProgressBlock? = nil,
completionHandler: ((Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
{
}
  • Resource是一个protocol,URL遵守该protocol,并将absoluteString当做CacheKey,如需自定义cacheKey、downloadURL,使用ImageResource替代Resource
    1
    2
    3
    4
    extension URL: Resource {
    public var cacheKey: String { return absoluteString }
    public var downloadURL: URL { return self }
    }