TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Depends on: | |
AFNetworking | ~> 2.0 |
EGOCache | ~> 2.0 |
WTExtension/UIImage+WTExtension | >= 1.2.0 |
WTURLImageView is a subclass of UIImageView that load images from Internet using AFNetworking, with the following features
Simplest call:
[imageView setURL:url];
Call with options:
[imageView setURL:url
fillType:fillType
options:options
placeholderImage:placeholderImage
failedImage:failedImage
diskCacheTimeoutInternal:diskCacheTimeInterval];
where you can set different fillType:
UIImageResizeFillTypeNoResize
The class will not rely on the contentMode to set the aspect ratio of the image. It will resize to the size of the imageView unless fillType==UIImageResizeFillTypeNoResize. It is because it is easier to do animation using layer. So you will find that if you set fillType to UIImageResizeFillTypeNoResize, most transiton animations will not run properly.
various options:
It may be troublesome to set options every time, so you can use a helper class to preset settings:
WTURLImageViewPreset *preset = [][WTURLImageViewPreset alloc] init];
preset.placeholderImage = [UIImage imageNamed:@"placeholder"];
[imageView setURL: url preset:preset];
Or you can set the default settings:
WTURLImageViewPreset *preset = [WTURLImageViewPreset defaultPreset];
preset.placeholderImage = [UIImage imageNamed:@"placeholder"];
that all [WTURLImageView setURL:] will use the preset settings.
Check the sample code for details.
git clone https://github.com/waterlou/WTURLImageView.git
cd WTURLImageView
pod install
open WTURLImageViewDemo.xcworkspace
If you are using AFNetworking 1.x, please use 1.x version of the source. If you are using AFNetworking 2.x, please use 2.x version. Note that AFNetworking 2.x can only support iOS 6.0 or above.
These specifications and CocoaPods are available under the MIT license.