聲明處: FLAnimatedImageView+WebCache.h
概述
FLAnimatedImage圖片視圖類的分類,把它掛到SDWebImage系統(tǒng)上。與基礎(chǔ)分類(UIImageView(WebCache))非常的相似。
任務(wù)
- sd_setImageWithURL:- sd_setImageWithURL:placeholderImage:- sd_setImageWithURL:placeholderImage:options:- sd_setImageWithURL:completed:- sd_setImageWithURL:placeholderImage:completed:- sd_setImageWithURL:placeholderImage:options:completed:- sd_setImageWithURL:placeholderImage:options:progress:completed:
實(shí)例方法
sd_setImageWithURL:
- (void)sd_setImageWithURL:(nullable NSURL *)url
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。
參數(shù)
url
圖片的url。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:completed:
- (void)sd_setImageWithURL:(nullable NSURL *)url completed:(nullable SDExternalCompletionBlock)completedBlock
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。
參數(shù)
url
圖片的url。
completedBlock
操作完成時(shí)調(diào)用塊。這個(gè)塊沒(méi)有返回值,帶有參數(shù),第一個(gè)參數(shù)為請(qǐng)求的UIImage,如果發(fā)生錯(cuò)誤這個(gè)值為nil。第二個(gè)參數(shù)為一個(gè)NSError的內(nèi)容。第三個(gè)參數(shù)是一個(gè)Boolean值,指示圖片是從本地緩存中恢復(fù),還是從網(wǎng)絡(luò)獲取。第四個(gè)參數(shù)為原始的圖片url。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:placeholderImage:
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。在請(qǐng)求完成前使用默認(rèn)圖片。
參數(shù)
url
圖片的url。
placeholder
圖片初始化內(nèi)容,直到圖片請(qǐng)求完成。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:placeholderImage:completed:
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。在請(qǐng)求完成前使用默認(rèn)圖片。
參數(shù)
url
圖片的url。
placeholder
圖片初始化內(nèi)容,直到圖片請(qǐng)求完成。
completedBlock
操作完成時(shí)調(diào)用塊。這個(gè)塊沒(méi)有返回值,帶有參數(shù),第一個(gè)參數(shù)為請(qǐng)求的UIImage,如果發(fā)生錯(cuò)誤這個(gè)值為nil。第二個(gè)參數(shù)為一個(gè)NSError的內(nèi)容。第三個(gè)參數(shù)是一個(gè)Boolean值,指示圖片是從本地緩存中恢復(fù),還是從網(wǎng)絡(luò)獲取。第四個(gè)參數(shù)為原始的圖片url。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:placeholderImage:options:
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。在請(qǐng)求完成前使用默認(rèn)圖片。
參數(shù)
url
圖片的url。
placeholder
圖片初始化內(nèi)容,直到圖片請(qǐng)求完成。
options
下載圖片時(shí)使用的選項(xiàng)。可能的值詳見(jiàn)SDWebImageOptions。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:placeholderImage:options:completed:
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。在請(qǐng)求完成前使用默認(rèn)圖片。
參數(shù)
url
圖片的url。
placeholder
圖片初始化內(nèi)容,直到圖片請(qǐng)求完成。
options
下載圖片時(shí)使用的選項(xiàng)??赡艿闹翟斠?jiàn)SDWebImageOptions。
completedBlock
操作完成時(shí)調(diào)用塊。這個(gè)塊沒(méi)有返回值,帶有參數(shù),第一個(gè)參數(shù)為請(qǐng)求的UIImage,如果發(fā)生錯(cuò)誤這個(gè)值為nil。第二個(gè)參數(shù)為一個(gè)NSError的內(nèi)容。第三個(gè)參數(shù)是一個(gè)Boolean值,指示圖片是從本地緩存中恢復(fù),還是從網(wǎng)絡(luò)獲取。第四個(gè)參數(shù)為原始的圖片url。
聲明處
FLAnimatedImageView+WebCache.h
sd_setImageWithURL:placeholderImage:options:progress:completed:
- (void)sd_setImageWithURL:(nullable NSURL *)url placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options progress:(nullable SDWebImageDownloaderProgressBlock)progressBlock completed:(nullable SDExternalCompletionBlock)completedBlock
討論
根據(jù)給定的url加載圖片,也可能是從緩存或已下載中加載。加載圖片到這個(gè)ImageView中。靜態(tài)庫(kù)和動(dòng)態(tài)庫(kù)都支持。進(jìn)行異步加載圖片并緩存圖片。在請(qǐng)求完成前使用默認(rèn)圖片。
注意:進(jìn)度塊在后臺(tái)隊(duì)列中執(zhí)行。
參數(shù)
url
圖片的url。
placeholder
圖片初始化內(nèi)容,直到圖片請(qǐng)求完成。
options
下載圖片時(shí)使用的選項(xiàng)??赡艿闹翟斠?jiàn)SDWebImageOptions。
progressBlock
當(dāng)圖片下載過(guò)程中這個(gè)塊被調(diào)用。
completedBlock
操作完成時(shí)調(diào)用塊。這個(gè)塊沒(méi)有返回值,帶有參數(shù),第一個(gè)參數(shù)為請(qǐng)求的UIImage,如果發(fā)生錯(cuò)誤這個(gè)值為nil。第二個(gè)參數(shù)為一個(gè)NSError的內(nèi)容。第三個(gè)參數(shù)是一個(gè)Boolean值,指示圖片是從本地緩存中恢復(fù),還是從網(wǎng)絡(luò)獲取。第四個(gè)參數(shù)為原始的圖片url。
聲明處
FLAnimatedImageView+WebCache.h
// END 今天看了YY大神的文檔,瞬間覺(jué)得iOS其實(shí)也有很多東西需要學(xué)習(xí)的,也需要查看源碼并知道其中的原理。多看看別人的代碼真的可以打開(kāi)眼界。不然一直以為iOS編寫業(yè)務(wù)邏輯就是全世界了。 希望我還沒(méi)有被淘汰吧。