Skip to content

noblakit01/SwiftyImageCache

Repository files navigation

SwiftyImageCache

Codacy Badge

Helper framework to cache image with url in Swift iOS.

Requirements

  • iOS 8.0+
  • Xcode 8+
  • Swift 3

Installation

CocoaPods

To integrate PhotoCollectionView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'SwiftyImageCache', '~> 1.2.2'

Then, run the following command:

$ pod install

Manually

  • Drag and drop Sources folder into your project.

Usage

Convenient UIImageView

Set url to imageview.

imageView.setUrl(url)

Design for UITableView/UICollectionView asynchronous image. Only need setUrl from any UIImageView in UITableViewCell/UICollectionViewCell.

ImageCache

Use ImageCache object to cache your image from URL

	let cache = ImageCache()
	cache.loadImage(atUrl: url, completion: { (urlString, image) in
	})

or use default cache

	ImageCache.default.loadImage(atUrl: url, completion: { (urlString, image) in
	})

CacheType

You can config cacheType

	ImageCache.default.cacheType = .disk // (default mode, recommendation)
	ImageCache.default.cacheType = .ram

TODO

Todo

License

MIT