CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

RVSImageLoader 0.0.3

RVSImageLoader 0.0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Paul-Emmanuel Garcia.



ImageLoader

Simple image loader in swift

Usage

Import the library

To use it on your project you need to import the framework.

// Swift
import ImageLoader

General Use cases

  • Simple load of an image: This will automatically start the loading of the image.
ImageLoader.default.load("https://assets-cdn.github.com/images/modules/open_graph/github-mark.png") {
    image, error in
    self.imageView.image = image
}
  • Handle image request:
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