Latest 2.4.0
Homepage https://github.com/AnthonyMDev/ImageValet
License MIT
Platforms ios 9.0, tvos 10.1, requires ARC
Dependencies Alamofire, AlamofireImage
Frameworks UIKit
Authors

Version
License
Platform

ImageValet allows you to lazy load a UIImage from anywhere! It supports sychronous or asychronous loading of images and provides functionality for using a placeholder image while loading asychronously.

Usage

An ImageValet stores information to lazily load a UIImage and can be created from a variety of image sources.

Sources

Each enum value provides the ability to load an image from a different source.

NSURL

let myImageURL = NSURL(string: "http://www.example.com/myImage.jpg")!
let placeholderImage = UIImage()

let valet = ImageValet(source: .URL(myImageURL, placeholder: placeholderImage)

NSURLRequest

let myImageURL = NSURL(string: "http://www.example.com/myImage.jpg")!
let request = NSMutableURLRequest(URL: myImageURL)
request.setValue("password", forHTTPHeaderField: "Authorization")
let placeholderImage = UIImage()

let valet = ImageValet(source: .URLRequest(request, placeholder: placeholderImage)

Operation

let placeholderImage = UIImage()

let valet = ImageValet(source: .Operation({ (completion) -> Void in

    // Do something to get your image

    completion(.Success(image))

}, placeholder: placeholderImage))

InMemory

let myImage = UIImage()

let valet = ImageValet(source:.InMemory(image: myImage))

Lazy Loading

You can set the image for an ImageValet to a UIImageView with deliverToImageView(imageView: UIImageView). The placeholder image will be used while the image is downloaded, and the image will be downloaded lazily only once this method is called.

let myImageURL = NSURL(string: "http://www.example.com/myImage.jpg")!
let placeholderImage = UIImage()

let valet = ImageValet(source: .URL(myImageURL, placeholder: placeholderImage)

let UIImageView = UIImageView()

valet.deliverToImageView(imageView)
// or
imageView.iv_deliverImage(valet)

ImageValet can also deliver an image asynchronously using a closure.

let valet = ImageValet(source: .URL(myImageURL, placeholder: placeholderImage)

valet.deliver { result in
  // Do something when the image is delivered
}

Requirements

Installation

ImageValet is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "ImageValet"

Author

Anthony Miller, [email protected]

License

ImageValet is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ImageValet",
    "version": "2.4.0",
    "summary": "Delivers an image from a local or remote source to a `UIImageView` or  closure, using `AlamofireImage` for asynchronous requests.",
    "swift_version": "4.2",
    "homepage": "https://github.com/AnthonyMDev/ImageValet",
    "license": "MIT",
    "authors": {
        "Anthony Miller": "[email protected]"
    },
    "source": {
        "git": "https://github.com/AnthonyMDev/ImageValet.git",
        "tag": "2.4.0"
    },
    "social_media_url": "https://twitter.com/AnthonyMDev",
    "requires_arc": true,
    "platforms": {
        "ios": "9.0",
        "tvos": "10.1"
    },
    "source_files": "Pod/Source/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "Alamofire": [
            "~> 4.7"
        ],
        "AlamofireImage": [
            "~> 3.3"
        ]
    }
}

Pin It on Pinterest

Share This