Latest 0.0.3
Homepage https://github.com/paulemmanuel-garcia/ImageLoader
License MIT
Platforms ios 10.1
Authors

ImageLoader

Simple image loader in swift

Build Status
CocoaPods
Carthage compatible
CocoaPods
CocoaPods

Usage

Import the library

To use it in your project, import the framework.

// Swift
import ImageLoader

General Use cases

  • Simply load 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
    }

    Or use the UIImageView extension:

    let imageView = UIImageView.imageView(with: "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png")
    // or
    existinImageView.load(with: "https://assets-cdn.github.com/images/modules/open_graph/github-mark.png")
  • 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.start()

To monitor the request’s progress, 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

Latest podspec

{
    "name": "RVSImageLoader",
    "version": "0.0.3",
    "summary": "Simple image loader in swift",
    "description": "Simple image loader in swift.",
    "homepage": "https://github.com/paulemmanuel-garcia/ImageLoader",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Paul-Emmanuel Garcia": "[email protected]"
    },
    "social_media_url": "http://twitter.com/pemgarcia",
    "platforms": {
        "ios": "10.1"
    },
    "source": {
        "git": "https://github.com/paulemmanuel-garcia/ImageLoader.git",
        "commit": "7c19281c84da814da548f6a4bade40d135535740",
        "tag": "0.0.3"
    },
    "source_files": "ImageLoader",
    "exclude_files": "Classes/Exclude",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This