Saffron
Saffron is a framework that gives a helping hand to download images and manage caches.
Features
- Generic Cache struct that can cache everything.
- 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
swift
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
var stringCache = Cache<String>(cacheDirectoryPath: cachePath)
// write to cache
stringCache.write(key, value: value)
// fetch from cache
let cachedString = stringCache.fetch(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)
}
API Documentation
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.