Skip to content

A SDWebImage plugin to integrate YYImage & YYCache for image rendering & caching

License

Notifications You must be signed in to change notification settings

MahranBayed/SDWebImageYYPlugin

 
 

Repository files navigation

SDWebImageYYPlugin

CI Status Version License Platform Carthage compatible codecov

What's for

SDWebImageYYPlugin is a plugin for SDWebImage framework, which provide the image loading support for YYImage (including YYImage's decoding system and YYAnimatedImageView) and YYCache cache system.

By using SDWebImageYYPlugin, you can use all you familiar SDWebImage's loading method, on the YYAnimatedImageView.

And you can also use YYCache instead of SDImageCache for image cache system, which may better memory cache performance (By taking advanced of LRU algorithm), and disk cache performance (By taking advanced of sqlite blob storage)

Usage

YYImage Plugin

To load a network image, simply call the View Category method like UIImageView.

  • Objective-C
YYAnimatedImageView *imageView;
[imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.gif"]];
  • Swift
let imageView: YYAnimatedImageView
imageView.sd_setImage(with: URL(string: "http://www.domain.com/path/to/image.gif"))

For advanced user, you can embed YYImageDecoder && YYImageEncoder to SDWebImage by using the wrapper class SDImageYYCoder. See Custom Coder wiki in SDWebImage.

  • Objective-C
// Register YYImage decoder/encoder as coder plugin
[SDImageCodersManager.sharedManager addCoder:SDImageYYCoder.sharedCoder];
  • Swift
// Register YYImage decoder/encoder as coder plugin
SDImageCodersManager.shared.addCoder(SDImageYYCoder.shared)

YYCache Plugin

To enable YYCache instead of SDImageCache, you can bind the cache for shared manager, or create a custom manager instead.

  • Objective-C
// Use `YYCache` for shared manager
SDWebImageManger.defaultImageCache = [YYCache cacheWithName:@"name"];
  • Swift
// Use `YYCache` for shared manager
SDWebImageManger.defaultImageCache = YYCache(name: "name")

You can also use YYMemoryCache or YYDiskcache to customize memory cache / disk cache only. See Custom Cache wiki in SDWebImage.

  • Objective-C
// Use `YYMemoryCache` for shared `SDImageCache` memory cache implementation
SDImageCacheConfig.defaultCacheConfig.memoryCacheClass = YYMemoryCache.class;
// Use `YYDiskCache` for shared `SDImageCache` disk cache implementation
SDImageCacheConfig.defaultCacheConfig.diskCacheClass = YYDiskCache.class;
  • Swift
// Use `YYMemoryCache` for `SDImageCache` memory cache implementation
SDImageCacheConfig.default.memoryCacheClass = YYMemoryCache.self
// Use `YYDiskCache` for `SDImageCache` disk cache implementation
SDImageCacheConfig.default.diskCacheClass = YYDiskCache.self

Requirements

  • iOS 8+
  • Xcode 9+

Installation

CocoaPods

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

pod 'SDWebImageYYPlugin'

SDWebImageYYPlugin contains two subspecs, YYCache and YYImage. You can choose to enable only some of them. By default will contains all subspecs.

pod 'SDWebImageYYPlugin/YYImage'
pod 'SDWebImageYYPlugin/YYCache'

Carthage

SDWebImageFLPlugin is available through Carthage.

github "SDWebImage/SDWebImageYYPlugin"

Carthage does not support like CocoaPods' subspec, the built framework will contains both YYCache && YYImage support.

Note because of limit of YYImage Carthage support, YYImage plugin with Carthage will not support WebP format. If you want to support WebP format, use CocoaPods instead.

Author

DreamPiggy, [email protected]

License

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

About

A SDWebImage plugin to integrate YYImage & YYCache for image rendering & caching

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 97.0%
  • Ruby 3.0%