iOS SDWebImage SDWebImageOptions

SDWebImage-SDWebImageOptions

typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) {
    /**
     * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying.
     * This flag disable this blacklisting.
     */
    SDWebImageRetryFailed = 1 << 0,

    /**
     * By default, image downloads are started during UI interactions, this flags disable this feature,
     * leading to delayed download on UIScrollView deceleration for instance.
     */
    SDWebImageLowPriority = 1 << 1,

    /**
     * This flag disables on-disk caching
     */
    SDWebImageCacheMemoryOnly = 1 << 2,

    /**
     * This flag enables progressive download, the image is displayed progressively during download as a browser would do.
     * By default, the image is only displayed once completely downloaded.
     */
    SDWebImageProgressiveDownload = 1 << 3,

    /**
     * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed.
     * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation.
     * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics.
     * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image.
     *
     * Use this flag only if you can't make your URLs static with embedded cache busting parameter.
     */
    SDWebImageRefreshCached = 1 << 4,

    /**
     * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for
     * extra time in background to let the request finish. If the background task expires the operation will be cancelled.
     */
    SDWebImageContinueInBackground = 1 << 5,

    /**
     * Handles cookies stored in NSHTTPCookieStore by setting
     * NSMutableURLRequest.HTTPShouldHandleCookies = YES;
     */
    SDWebImageHandleCookies = 1 << 6,

    /**
     * Enable to allow untrusted SSL certificates.
     * Useful for testing purposes. Use with caution in production.
     */
    SDWebImageAllowInvalidSSLCertificates = 1 << 7,

    /**
     * By default, images are loaded in the order in which they were queued. This flag moves them to
     * the front of the queue.
     */
    SDWebImageHighPriority = 1 << 8,
    
    /**
     * By default, placeholder images are loaded while the image is loading. This flag will delay the loading
     * of the placeholder image until after the image has finished loading.
     */
    SDWebImageDelayPlaceholder = 1 << 9,

    /**
     * We usually don't call transformDownloadedImage delegate method on animated images,
     * as most transformation code would mangle it.
     * Use this flag to transform them anyway.
     */
    SDWebImageTransformAnimatedImage = 1 << 10,
    
    /**
     * By default, image is added to the imageView after download. But in some cases, we want to
     * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance)
     * Use this flag if you want to manually set the image in the completion when success
     */
    SDWebImageAvoidAutoSetImage = 1 << 11
};

SDWebImageRetryFailed = 1 << 0
默認情況下,如果一個url在下載的時候失敗了,那么這個url會被加入黑名單并且library不會嘗試再次下載,這個flag會阻止library把失敗的url加入黑名單(簡單來說如果選擇了這個flag,那么即使某個url下載失敗了,sdwebimage還是會嘗試再次下載他

SDWebImageLowPriority = 1 << 1
默認情況下,圖片會在交互發(fā)生的時候下載(例如你滑動tableview的時候),這個flag會禁止這個特性,導(dǎo)致的結(jié)果就是在scrollview減速的時候,才會開始下載(也就是你滑動的時候scrollview不下載,你手從屏幕上移走,scrollview開始減速的時候才會開始下載圖片

SDWebImageCacheMemoryOnly = 1 << 2
這個flag禁止磁盤緩存,只有內(nèi)存緩存

SDWebImageProgressiveDownload = 1 << 3
這個flag會在圖片下載的時候就顯示(就像你用瀏覽器瀏覽網(wǎng)頁的時候那種圖片下載,一截一截的顯示(待確認))

SDWebImageRefreshCached = 1 << 4
一個圖片緩存了,還是會重新請求.并且緩存?zhèn)嚷砸罁?jù)NSURLCache而不是SDWebImage.URL不變,圖片會更新時使用

SDWebImageContinueInBackground = 1 << 5
啟動后臺下載,加入你進入一個頁面,有一張圖片正在下載這時候你讓app進入后臺,圖片還是會繼續(xù)下載(這個估計要開backgroundfetch才有用)

SDWebImageHandleCookies = 1 << 6
可以控制存在NSHTTPCookieStore的cookies.

SDWebImageAllowInvalidSSLCertificates = 1 << 7
允許不安全的SSL證書,在正式環(huán)境中慎用

SDWebImageHighPriority = 1 << 8
默認情況下,image在裝載的時候是按照他們在隊列中的順序裝載的(就是先進先出).這個flag會把他們移動到隊列的前端,并且立刻裝載,而不是等到當(dāng)前隊列裝載的時候再裝載.

SDWebImageDelayPlaceholder = 1 << 9
默認情況下,占位圖會在圖片下載的時候顯示.這個flag開啟會延遲占位圖顯示的時間,等到圖片下載完成之后才會顯示占位圖.

SDWebImageTransformAnimatedImage = 1 << 10
是否transform圖片

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、通過CocoaPods安裝項目名稱項目信息 AFNetworking網(wǎng)絡(luò)請求組件 FMDB本地數(shù)據(jù)庫組件 SD...
    陽明AI閱讀 16,171評論 3 119
  • 1.ios高性能編程 (1).內(nèi)層 最小的內(nèi)層平均值和峰值(2).耗電量 高效的算法和數(shù)據(jù)結(jié)構(gòu)(3).初始化時...
    歐辰_OSR閱讀 30,192評論 8 265
  • 項目中一直都有使用SDWebImage,對這個框架有一定的了解,但是體系卻未能貫通,因此特地整理下,主要參考: i...
    林大鵬閱讀 1,656評論 2 13
  • 在這個匆忙的城市里,白天的時光總是眨眼即過,還沒來得及生活,就已是被生活拖進了夜里。 細細想來,人...
    醬醋茶七七閱讀 365評論 0 2
  • 早安!又是一夜只睡了三個小時,為了今天上午三個小時的課程。盡管昨天寫了文章,說要白天把課程備好,改變自己這個臨時突...
    綻蕊向陽閱讀 178評論 0 0

友情鏈接更多精彩內(nèi)容