Kingfisher는 Swift에서 이미지 다운로드와 캐싱을 간편하게 처리하기 위한 오픈소스 라이브러리입니다.
네트워크 이미지를 쉽게 불러오고, 성능 최적화를 위한 캐싱 기능을 제공합니다.
.package(url: "https://github.com/onevcat/Kingfisher.git", from: "7.0.0")
import Kingfisher
let url = URL(string: "https://example.com/image.jpg")
imageView.kf.setImage(with: url)
kf 네임스페이스를 통해 Kingfisher 기능 사용imageView.kf.setImage(
with: url,
placeholder: UIImage(named: "placeholder")
)
imageView.kf.setImage(
with: url,
options: [
.transition(.fade(0.3)),
.cacheOriginalImage
]
)
캐시 초기화:
ImageCache.default.clearMemoryCache()
ImageCache.default.clearDiskCache()
let processor = RoundCornerImageProcessor(cornerRadius: 20)
imageView.kf.setImage(
with: url,
options: [.processor(processor)]
)
Kingfisher는 iOS에서 네트워크 이미지 처리와 캐싱을 단순화하는 강력한 라이브러리입니다.
네트워크 기반 UI 개발에서 필수적으로 고려할 만한 도구입니다.