UIButton(WebCache)分類說明


聲明處: UIButton+WebCache.h


概述

整合UIButton視圖與SDWebImage異步下載和緩存遠程圖片。

任務

  • - sd_currentImageURL
  • - sd_imageURLForState:
  • - sd_setImageWithURL:forState:
  • - sd_setImageWithURL:forState:placeholderImage:
  • - sd_setImageWithURL:forState:placeholderImage:options:
  • - sd_setImageWithURL:forState:completed:
  • - sd_setImageWithURL:forState:placeholderImage:completed:
  • - sd_setImageWithURL:forState:placeholderImage:options:completed:
  • - sd_setBackgroundImageWithURL:forState:
  • - sd_setBackgroundImageWithURL:forState:placeholderImage:
  • - sd_setBackgroundImageWithURL:forState:placeholderImage:options:
  • - sd_setBackgroundImageWithURL:forState:completed:
  • - sd_setBackgroundImageWithURL:forState:placeholderImage:completed:
  • - sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:
  • - sd_cancelImageLoadForState:
  • - sd_cancelBackgroundImageLoadForState:

實例方法

sd_cancelBackgroundImageLoadForState:

- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state

討論

取消當前的背景圖下載。

聲明處

UIButton+WebCache.h

sd_cancelImageLoadForState:

- (void)sd_cancelImageLoadForState:(UIControlState)state

討論

取消當前的圖片下載。

聲明處

UIButton+WebCache.h

sd_currentImageURL

- (nullable NSURL *)sd_currentImageURL

討論

獲取當前的圖片URL。

聲明處

UIButton+WebCache.h

sd_imageURLForState:

- (nullable NSURL *)sd_imageURLForState:(UIControlState)state

討論

根據一個控制狀態獲取圖片URL。

參數

state

你想知道的哪個狀態的URL。狀態值的描述在UIControlState中。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state

討論

根據一個url設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:completed:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:placeholderImage:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder

討論

根據一個url和默認圖設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:placeholderImage:completed:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url和默認圖設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:placeholderImage:optons:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options

討論

根據一個url,默認圖和自定義選項來設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

options

下載圖片時使用的選項??赡艿闹翟斠奡DWebImageOptions。

聲明處

UIButton+WebCache.h

sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:

- (void)sd_setBackgroundImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url,默認圖和自定義選項來設置背景視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

options

下載圖片時使用的選項。可能的值詳見SDWebImageOptions。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state

討論

根據一個url來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:completed:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:placeholderImage:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder

討論

根據一個url和默認圖來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:placeholderImage:completed:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url和默認圖選項來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:placeholderImage:options:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options

討論

根據一個url,默認圖和自定義選項來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

options

下載圖片時使用的選項。可能的值詳見SDWebImageOptions。

聲明處

UIButton+WebCache.h

sd_setImageWithURL:forState:placeholderImage:options:completed:

- (void)sd_setImageWithURL:(nullable NSURL *)url forState:(UIControlState)state placeholderImage:(nullable UIImage *)placeholder options:(SDWebImageOptions)options completed:(nullable SDExternalCompletionBlock)completedBlock

討論

根據一個url,默認圖和自定義選項來設置圖片視圖的圖片。
下載是異步和會緩存的。

參數

url

圖片的url。

state

使用指定標題的狀態。狀態值的描述在UIControlState中。

placeholder

圖片初始化內容,直到圖片請求完成。

options

下載圖片時使用的選項??赡艿闹翟斠奡DWebImageOptions。

completedBlock

操作完成時調用塊。這個塊沒有返回值,帶有參數,第一個參數為請求的UIImage,如果發生錯誤這個值為nil。第二個參數為一個NSError的內容。第三個參數是一個Boolean值,指示圖片是從本地緩存中恢復,還是從網絡獲取。第四個參數為原始的圖片url。

聲明處

UIButton+WebCache.h

// END 接口非常的相似,并且有sd的前綴,作為第三方庫很推薦。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容