TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2018 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Meniny.
Imagery
is a lightweight library for downloading and cacheing image from the web.
You are welcome to fork and submit pull requests.
Imagery
is open-sourced software, licensed under the MIT
license.
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)
}
}
}
let task = imageView.imagery.setImage(with: url, placeholder: placeholder)
task.cancel()
ImageryManager.cancelAll()
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
}