Helper framework to cache image with url in Swift iOS.
- iOS 8.0+
- Xcode 8+
- Swift 3
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
- Drag and drop
Sources
folder into your project.
Set url to imageview.
imageView.setUrl(url)
Design for UITableView
/UICollectionView
asynchronous image. Only need setUrl
from any UIImageView
in UITableViewCell
/UICollectionViewCell
.
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
})
You can config cacheType
ImageCache.default.cacheType = .disk // (default mode, recommendation)
ImageCache.default.cacheType = .ram