TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2015 |
Maintained by Jérôme Morissard.
JMAnimatedImageView is a performant subclass of UIImageView:
0.2.4 :
Simply replace your UIImageView
instances with instances of JMAnimatedImageView
.
If using CocoaPods, the quickest way to try it out is to type this on the command line:
$ pod try JMAnimatedImageView
In your code, #import "JMAnimatedImageView.h"
and #import "JMAnimatedImageView.h"
//GIF example
@property (weak, nonatomic) IBOutlet JMAnimatedImageView *jmImageView;
[self.jmImageView reloadAnimationImagesFromGifNamed:@"rock"];
self.jmImageView.animationType = JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition;
[self.jmImageView startAnimating];
//PNG example with manual animation
@property (weak, nonatomic) IBOutlet JMAnimatedImageView *jmImageView;
self.jmImageView.animationDelegate = self;
self.jmImageView.animationDatasource = self;
[self.jmImageView reloadAnimationImages]; //<JMOImageViewAnimationDatasource>
self.jmImageView.animationType = JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition;
self.jmImageView.memoryManagementOption = JMAnimatedImageViewMemoryLoadImageLowMemoryUsage;
[self.jmImageView startAnimating];
@property (weak, nonatomic) IBOutlet JMAnimatedImageView *jmImageView;
[[JMApi sharedApi] downloadYourGifFileHasData:^(NSData *gifData) {
self.animatedImageView.animationType = JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition;
self.animatedImageView.memoryManagementOption = JMAnimatedImageViewMemoryLoadImageLowMemoryUsage;
[self.animatedImageView reloadAnimationImagesFromGifData:gifData fromUrl:url];
[self.animatedImageView startAnimating];
}];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *postOperation = [[AFHTTPRequestOperation alloc] initWithRequest:req];
[postOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
self.animatedImageView.animationType = JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition;
self.animatedImageView.memoryManagementOption = JMAnimatedImageViewMemoryLoadImageLowMemoryUsage;
[self.animatedImageView reloadAnimationImagesFromGifData:responseObject fromUrl:url];
[self.animatedImageView startAnimating];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
block(NO, nil);
}];
[postOperation start];
typedef NS_ENUM(NSUInteger, JMAnimatedImageViewAnimationType) {
JMAnimatedImageViewAnimationTypeInteractive = 0,
//Animation, carousel effect
JMAnimatedImageViewAnimationTypeManualSwipe,
//Automatic rotation, use animationDuration + animationRepeatCount
JMAnimatedImageViewAnimationTypeAutomaticLinear,
JMAnimatedImageViewAnimationTypeAutomaticLinearWithoutTransition,
JMAnimatedImageViewAnimationTypeAutomaticReverse,
};
typedef NS_ENUM(NSUInteger, JMAnimatedImageViewMemoryOption) {
JMAnimatedImageViewMemoryLoadImageSystemCache = 0, //images memory will be retain by system
JMAnimatedImageViewMemoryLoadImageLowMemoryUsage, //images loaded but not retained by the system
JMAnimatedImageViewMemoryLoadImageCustom //images loaded by you (JMOImageViewAnimationDatasource)
};
typedef NS_ENUM(NSUInteger, JMAnimatedImageViewOrder) {
JMAnimatedImageViewOrderNormal = 1,
JMAnimatedImageViewOrderReverse = -1
};