KI

Kingfisher

Image downloading and caching

Details

Language / Topic
swiftSwift
Category
Libraries
Source
onevcat

Rules

balanced
- Use `kf.setImage(with: url)` on `UIImageView`/SwiftUI `Image` — Kingfisher handles downloading, caching (memory + disk), and placeholder display.
- Configure cache limits with `ImageCache.default.memoryStorage.config.totalCostLimit` and `diskStorage.config.sizeLimit` for memory management.
- Use `.processor()` modifier for image transformations (resize, round corners, blur) — processors run before caching, so transformed images are cached too.
- Use `.placeholder()` for loading states and `.onFailure()` for error handling.
- Use `.processor()` for image transformations: resize, blur, round corners.
- Use `ImageCache.default.clearCache()` for cache management. Configure memory and disk limits.
- Use `.fade(duration:)` for smooth image transition animations.