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

STXImageCache 1.0.2

STXImageCache 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Feb 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Norbert Sroczyński.



  • By
  • Norbert Sroczyński

codebeat badge

STXImageCache is a lightweight, pure-Swift, easy to use library for downloading and caching images. It provides convenient UI extensions. It’s inspired by popular libraries like Kingfisher and SDWebImage.

Features

  • [x] UI extensions
  • [x] An asynchronous image downloader
  • [x] Cancelable downloading tasks
  • [x] Memory caching
  • [x] Disk caching
  • [x] A guarantee that the same URL won’t be downloaded several times
  • [x] High performance
  • [x] Use GCD and ARC

Requirements

  • iOS 9.0 or later
  • tvOS 9.0 or later
  • watchOS 2.0 or later
  • macOS 10.10 or later
  • Xcode 8.0 or later

Getting Started

Simplest usage

let url = URL(string: "image_url")!
imageView.stx.image(atURL: url)

Advanced usage

let url = URL(string: "image_url")!
let placeholder = UIImage(named: "placeholder")
let operation = imageView.stx.image(atURL: url, placeholder: placeholder, progress: { progress in
        // update progressView
    }, completion: { image, _ in
        // do image processing
        return image
    })

Using with UITableViewCell

import UIKit
import STXImageCache

final class Cell: UITableViewCell {
    var operation: STXImageOperation?
    @IBOutlet weak var progress: UIProgressView!

    override func prepareForReuse() {
        super.prepareForReuse()
        operation?.cancel()
    }

    func configure(withURL url: URL, placeholder: UIImage) {
        imageView?.image = nil
        progress.progress = 0
        self.progress.isHidden = false
        operation = imageView?.stx.image(atURL: url, placeholder: placeholder, progress: { progress in
            DispatchQueue.main.async {
                self.progress.setProgress(progress, animated: true)
            }
        }, completion: { image, _ in
            DispatchQueue.main.async {
                self.progress.isHidden = true
            }
            return image
        })
    }
}

Author

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Licenses

All source code is licensed under the MIT License.