TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Dec 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Paul-Emmanuel Garcia.
Simple image loader in swift
To use it on your project you need to import the framework.
// Swift
import ImageLoader
ImageLoader.default.load("https://assets-cdn.github.com/images/modules/open_graph/github-mark.png") {
image, error in
self.imageView.image = image
}
let imageRequest = ImageLoader.default.request("https://assets-cdn.github.com/images/modules/open_graph/github-mark.png") {
image, error in
self.imageView.image = image
}
You can cancel
/suspend
/restart
the request
imageRequest.cancel()
imageRequest.suspend()
imageRequest.restart()
To monitor the progress of the request you can implement the ImageRequestDelegate
func progress(_ request: ImageRequest, totalBytesSent: Int64, totalBytesExpected: Int64) {
print("\(Double(totalBytesSent) / Double(totalBytesExpected) * 100.0)%")
}
If you do not want to start right away the loading of the image you can use the autoStart parameter
let imageRequest = ImageLoader.default.request("https://assets-cdn.github.com/images/modules/open_graph/github-mark.png", autoStart = false) {
image, error in
self.imageView.image = image
}
// Do Stuff
imageRequest.start()
By default images are cached, to disable that behavior:
let imageRequest = ImageLoader.default("https://assets-cdn.github.com/images/modules/open_graph/github-mark.png") {
image, error in
self.imageView.image = image
}
imageRequest.shouldCacheResult = false