Last active
April 18, 2020 10:54
-
-
Save nurtugan/bd0c5e6103cabb6e4fd49408538d24f5 to your computer and use it in GitHub Desktop.
Kingfisher configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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