项目作者: conmulligan

项目描述 :
Asynchronous image downloader and cache for iOS.
高级语言: Swift
项目地址: git://github.com/conmulligan/vinci.git
创建时间: 2018-06-11T16:49:01Z
项目社区:https://github.com/conmulligan/vinci

开源协议:MIT License

下载


Vinci

CI Status
Version
License
Platform

Vinci is an asynchronous image downloader and cache for iOS.

Note: Vinci is early in development and, although stable, is missing some important features.

Roadmap

Done

  • Asychronous image downloading (0.1.0).
  • Download queue (0.1.0).
  • Combined memory and disk cache (0.1.0).
  • Image modifiers (0.2.0).
  • Support for caching images post-modification (0.2.0).

Outstanding

  • Automatic cache expiration.
  • UIImageView binding.

Usage

You can use the shared Vinci singleton and the request factory method to fetch an image like so:

  1. Vinci.shared.request(with: url) { (image, isCached) in
  2. imageView.image = image
  3. }

A Vinci instance can also initialized with custom URLSession and VinciCache instances:

  1. let session = URLSession.shared
  2. let cache = VinciCache()
  3. let vinci = Vinci(session: session, cache: cache)

Modifiers

You can pass an optional array of Modifiers to change the image before it’s passed to the completion hander:

  1. let modifiers: [Modifier] = [
  2. MonoModifier(color: UIColor.gray, intensity: 1.0),
  3. ScaleModifier(size: imageView.frame.size)
  4. ]
  5. Vinci.shared.request(with: url, modifiers: modifiers) { (image, isCached) in
  6. imageView.image = image
  7. }

Vinci includes a number of modifiers by default:

  • ScaleModifier scales an image to a specific size.
  • MonoModifier uses CIColorMonochrome to color tint an image.
  • ClosureModifier accepts a closure which applies a custom modification.

Additional modifiers can be created by implementing the Modifier protocol.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Vinci is available through CocoaPods. To install it, add the following line to your Podfile:

  1. pod 'Vinci'

Author

Conor Mulligan, conmulligan@gmail.com

License

Vinci is available under the MIT license. See the LICENSE file for more info.