/Saffron

Downloading and caching images like a charm.

Primary LanguageSwiftMIT LicenseMIT

# Saffron [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/CaptainTeemo/Saffron.svg?branch=master)](https://travis-ci.org/CaptainTeemo/Saffron) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/CaptainTeemo/Saffron/master/LICENSE.md) [![GitHub release](https://img.shields.io/github/release/CaptainTeemo/Saffron.svg)](https://github.com/CaptainTeemo/Saffron/releases)

Saffron is a framework that gives a helping hand to download images and manage caches.

Features

  • Thread safe and generic cache mechanism.
  • Convenient extensions for UIImageView that do download and cache things for you.
  • Built in loading animator which can be configured.
  • Options to process image (corner radius, scale and GaussianBlur).
  • GIF image support.
  • Easy to use.

At a glance

imageView.sf_setImage(#some image url string#)

That's all!

Process image

imageView.sf_setImage(url, options: [.ScaleToFill(size), .CornerRadius(8), .GaussianBlur(10))
// image would be processed in order and assign the result image to imageView.
Cache
let stringCache = Cache<String, String>()
// write to cache
stringCache[key] = "value"

// fetch from cache
let cachedString = stringCache[key]
GIF image support

Circle reveal animation
func whereImageViewShouldBeInitialized() {
    let loader = DefaultAnimator(revealStyle: .Circle, reportProgress: false)
    imageView.sf_setAnimationLoader(loader)
}

Fade reveal animation
func whereImageViewShouldBeInitialized() {
    let loader = DefaultAnimator(revealStyle: .Fade, reportProgress: false)
    imageView.sf_setAnimationLoader(loader)
}

Report download progress
func whereImageViewShouldBeInitialized() {
    let loader = DefaultAnimator(revealStyle: .Fade, reportProgress: true)
    imageView.sf_setAnimationLoader(loader)
}

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Carthage

Put github "CaptainTeemo/Saffron" in your cartfile and run carthage update from terminal, then drag built framework to you project.