Created
June 28, 2021 03:53
-
-
Save gfdac/dac02c0b2e78d84b267bc070a97175dc to your computer and use it in GitHub Desktop.
Swift 5 Kingfisher Library refactory
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
if(settings.imageUrl.hasValue){ | |
let resource = ImageResource(downloadURL: URL.specialURL(specialString: settings.imageUrl!)) | |
let options = [KingfisherOptionsInfoItem.cacheOriginalImage] | |
logoImageView?.kf.setImage(with: resource, options: options, completionHandler: { (result) in | |
DispatchQueue.main.async{ | |
DispatchQueue.main.async { | |
let image = try? result.get().image | |
if let image = image { | |
let imgSize = self.logoImageView?.frame.size ?? CGSize(width: 0, height: 0) | |
let imgCropped = image.resizeTopLeftToFill(containerSize : imgSize) | |
self.logoImageView?.image = imgCropped | |
} | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment