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

Imagery 1.2.0

Imagery 1.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2018
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Meniny.



Imagery 1.2.0

Imagery

What’s this?

Imagery is a lightweight library for downloading and cacheing image from the web.

Requirements

  • iOS 8.0+
  • macOS 10.10+
  • tvOS 9.0+
  • watchOS 2.0+
  • Xcode 8 with Swift 3

Contribution

You are welcome to fork and submit pull requests.

License

Imagery is open-sourced software, licensed under the MIT license.

Samples

Basic Usage

Use iOS for example

import Foundation
import UIKit
import Imagery

class ViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var button: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
        button.tintColor = .clear

        if let url = URL(string: "https://i.loli.net/2017/07/25/597765d9704f0.png") {

            let placeholder = UIImage(named: "placeholder")
            // let placeholder = #imageLiteral(resourceName: "placeholder")

            button.imagery.setBackgroundImage(with: url, for: .normal, placeholder: nil)
            //button.imagery.setImage(with: url, for: .normal)

            imageView.imagery.setImage(with: url,
                                       placeholder: placeholder,
                                       options: nil,
                                       progressBlock: nil,
                                       completionHandler: nil)
            //imageView.imagery.setImage(with: url, placeholder: placeholder)
        }
    }
}

Cancel

let task = imageView.imagery.setImage(with: url, placeholder: placeholder)
task.cancel()
ImageryManager.cancelAll()

Clean Caches

ImageryManager.clearAllCache()

ImageryManager.clearMemoryCache()
ImageryManager.clearDiskCache {
    // code
}
ImageryManager.cleanExpiredDiskCache {
    // code
}
// MARK: Class Methods
ImageryCache.clearMemoryCache()
ImageryCache.clearDiskCache()
ImageryCache.cleanExpiredDiskCache()
ImageryCache.clearDiskCache {
    // code
}
ImageryCache.cleanExpiredDiskCache {
    // code
}

// MARK: Instance Methods
ImageryCache.default.clearMemoryCache()
ImageryCache.default.clearDiskCache()
ImageryCache.default.cleanExpiredDiskCache()
ImageryCache.default.clearDiskCache {
    // code
}
ImageryCache.default.cleanExpiredDiskCache {
    // code
}