Skip to content

Instantly share code, notes, and snippets.

@nurtugan
Last active April 18, 2020 10:54
Show Gist options
  • Save nurtugan/bd0c5e6103cabb6e4fd49408538d24f5 to your computer and use it in GitHub Desktop.
Save nurtugan/bd0c5e6103cabb6e4fd49408538d24f5 to your computer and use it in GitHub Desktop.
Kingfisher configs
import Kingfisher
import UIKit
extension UIImageView {
static func clearImageCache() {
KingfisherManager.shared.cache.clearMemoryCache()
KingfisherManager.shared.cache.clearDiskCache()
}
/// UIImageView+: Method for downloading image
func setImage(
with urlAsString: String?,
completionHandler: ((Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
) {
let url = URL(string: urlAsString ?? "")
let processor = DownsamplingImageProcessor(size: size)
kf.indicatorType = .activity
kf.setImage(
with: url,
options: [
.processor(processor),
.scaleFactor(UIScreen.main.scale),
.transition(.fade(1)),
.cacheOriginalImage
],
progressBlock: nil,
completionHandler: completionHandler
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment