Latest 1.0.2
Homepage https://github.com/stxnext/STXImageCache
License MIT
Platforms ios 9.0, tvos 9.0, osx 10.10, watchos 2.0, requires ARC
Authors

STXImageCache

Carthage compatible
Pod Version
Pod Platform
Pod License
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

Installation

Cocoapods

pod 'STXImageCache', '~> 1.0.1'

Carthage

github "stxnext/STXImageCache" ~> 1.0.1

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.

Latest podspec

{
    "name": "STXImageCache",
    "version": "1.0.2",
    "summary": "A lightweight and pure-Swift library for downloading and caching images.",
    "description": "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.",
    "homepage": "https://github.com/stxnext/STXImageCache",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Norbert Sroczyu0144ski": "[email protected]"
    },
    "platforms": {
        "ios": "9.0",
        "tvos": "9.0",
        "osx": "10.10",
        "watchos": "2.0"
    },
    "source": {
        "git": "https://github.com/stxnext/STXImageCache.git",
        "tag": "1.0.2"
    },
    "ios": {
        "source_files": [
            "Source/*.swift",
            "STXImageCache.h"
        ],
        "exclude_files": [
            "Source/STXImageCache+NSButtonExtensions.swift"
        ]
    },
    "watchos": {
        "source_files": [
            "Source/*.swift",
            "STXImageCache.h"
        ],
        "exclude_files": [
            "Source/STXImageCache+NSButtonExtensions.swift",
            "Source/STXImageCache+UIButtonExtensions.swift"
        ]
    },
    "tvos": {
        "source_files": [
            "Source/*.swift",
            "STXImageCache.h"
        ],
        "exclude_files": [
            "Source/STXImageCache+NSButtonExtensions.swift"
        ]
    },
    "osx": {
        "source_files": [
            "Source/*.swift",
            "STXImageCache.h"
        ],
        "exclude_files": [
            "Source/STXImageCache+UIButtonExtensions.swift"
        ]
    },
    "public_header_files": [
        "STXImageCache.h"
    ],
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This