輕量級的零設置 iOS 圖像緩存器:Haneke
Haneke 是個輕量級的零設置 iOS 圖像緩存器。Haneke 可以調整圖像和內存以及硬盤的緩存大小。所有的步驟都在后臺進行,允許快速響應滾動。
特性:
- First-level memory cache using
NSCache
. - Second-level LRU disk cache using the file system.
- Zero-config
UIImageView
category to use the cache, optimized forUITableView
andUICollectionView
cell reuse. - Asynchronous and synchronous image retrieval.
- Background image resizing and file reading.
- Custom image transformations before and after resizing.
- Thread-safe.
- Automatic cache eviction on memory warnings or disk capacity reached.
- Preloading images from the disk cache into memory on startup.
HNKCacheFormat *format = [[HNKCacheFormat alloc] initWithName:@"thumbnail"]; format.size = CGSizeMake(320, 240); format.scaleMode = HNKScaleModeAspectFill; format.compressionQuality = 0.5; format.diskCapacity = 1 * 1024 * 1024; // 1MB format.preloadPolicy = HNKPreloadPolicyLastSession; imageView.hnk_cacheFormat = format;
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!