TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2016 |
SPMSupports SPM | ✗ |
Maintained by Jérôme Gx.
An asynchronous image loader, with some magic including an UIImageView category for drop-in integration.
This library will allow you to load image from the web to any UIImageView thanks to the UIImageView category.
It is also a more capable low level loading library to get UIImage from the Internet allowing you to control the logic you want to put there.
Requirements
This library needs iOS7, nothing else is needed :)
You can install it from cocoapods (see Installation)
then import AAsyncImageLoader
If you want the drop-in version, it is simple as
imageView.aail_load(NSURL(string: "https://example.com/image.jpg")!, placeholder: UIImage(named: "placeholder_image"))
This libray includes some magic, and will work like a charm for your reusable cells.
It has a cancelation mechanism integrated
// example from the demo app
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let CellIdentifier = "Cell"
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier, forIndexPath: indexPath)
let name = Array<String>(data.keys)[indexPath.row]
let imageUrl = data[name]!
cell.textLabel?.text = name
cell.imageView?.aail_load(NSURL(string: imageUrl)!, placeholder: UIImage(named: "placeholder_image"))
return cell
}
you could also get more control, by using the core of the library to tweak configuration options like caching or also get to cancel the request
var myImage = UIImage()
let configuration = AAsyncImageLoaderConfiguration()
configuration.defineCachePolicy(.ForceReload)
let aasyncRequest = AAsyncImageLoader(configuration: configuration)
aasyncRequest.withUrl(NSURL(string: "https://example.com/image.jpg")!) {
image, error in
if let image = image {
myImage = image
// maybe do something with this image
// don't forget to get back on the main thread
} else {
// do something with the error
}
}
.load() // start the request
// later in the code you can cancel the request if needed
aasyncRequest.cancel()
To run the example project, clone the repo, and run pod install
from the Example directory first.
This library comes with unit testing, you can start them by checking out this repository into XCode and run it from there
If needed, you can also copy/past the AAsyncImageLoader* files into your app
AAsyncImageLoader is an open source project. If you’d like to contribute, please submit a pull request.
But you don’t have to write code, you can also:
If you found a bug and are willing to fix it, we will check your Pull Request and integrate it if relevant
AAsyncImageLoader is available under the MIT license. See the LICENSE file for more info.