@@ -17,7 +17,7 @@ @interface MFPictureBrowser()
@property (nonatomic, weak) UIScrollView *scrollView;
@property (nonatomic, weak) UILabel *pageTextLabel;
@property (nonatomic, weak) UITapGestureRecognizer *dismissTapGesture;
@property (nonatomic, strong) FLAnimatedImageView *endView;
@property (nonatomic, strong) UIImageView *endView;
@end

@implementation MFPictureBrowser
@@ -68,11 +68,10 @@ - (void)configuration {

#pragma mark - 公共方法

- (void)showImageFromView:(FLAnimatedImageView *)fromView picturesCount:(NSInteger)picturesCount currentPictureIndex:(NSInteger)currentPictureIndex {
- (void)showImageFromView:(UIImageView *)fromView picturesCount:(NSInteger)picturesCount currentPictureIndex:(NSInteger)currentPictureIndex {
[self showFromView:fromView picturesCount:picturesCount currentPictureIndex:currentPictureIndex];
for (NSInteger i = 0; i < picturesCount; i++) {
MFPictureView *pictureView = [self createImagePictureViewAtIndex:i];
[pictureView.imageView stopAnimating];
[self.pictureViews addObject:pictureView];
}
MFPictureView *pictureView = self.pictureViews[currentPictureIndex];
@@ -100,23 +99,19 @@ - (void)showFromView:(UIImageView *)fromView picturesCount:(NSInteger)picturesCo

- (MFPictureView *)createImagePictureViewAtIndex:(NSInteger)index {
id<MFPictureModelProtocol> pictureModel = [_delegate pictureBrowser:self pictureModelAtIndex:index];
FLAnimatedImageView *animtedImageView = [_delegate pictureBrowser:self imageViewAtIndex:index];
UIImageView *imageView = [_delegate pictureBrowser:self imageViewAtIndex:index];
MFPictureView *pictureView = [[MFPictureView alloc] initWithPictureModel:pictureModel];
[self configPictureView:pictureView index:index animtedImageView:animtedImageView];
[self configPictureView:pictureView index:index imageView:imageView];
return pictureView;
}

- (void)configPictureView:(MFPictureView *)pictureView index:(NSInteger)index animtedImageView:(FLAnimatedImageView *)animtedImageView {
- (void)configPictureView:(MFPictureView *)pictureView index:(NSInteger)index imageView:(UIImageView *)imageView {
[self.dismissTapGesture requireGestureRecognizerToFail:pictureView.imageView.gestureRecognizers.firstObject];
pictureView.pictureDelegate = self;
[self.scrollView addSubview:pictureView];
pictureView.index = index;
pictureView.size = self.size;
if (animtedImageView.image) {
pictureView.pictureSize = animtedImageView.image.size;
}else if (animtedImageView.animatedImage) {
pictureView.pictureSize = animtedImageView.animatedImage.size;
}
pictureView.pictureSize = imageView.image.size;
CGPoint center = pictureView.center;
center.x = index * _scrollView.width + _scrollView.width * 0.5;
pictureView.center = center;
@@ -132,7 +127,7 @@ - (void)showPictureView:(MFPictureView *)pictureView fromView:(UIImageView *)fro
self.pageTextLabel.alpha = 0;
}
} completionBlock:^{
[pictureView.imageView startAnimating];

}];
}

@@ -228,10 +223,8 @@ - (void)p_setPageText:(NSUInteger)index {
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSUInteger index = (scrollView.contentOffset.x / scrollView.width + 0.5);
if (self.currentIndex != index) {
MFPictureView *view = self.pictureViews[self.currentIndex];
[view.imageView stopAnimating];
MFPictureView *currentView = self.pictureViews[index];
[currentView.imageView startAnimating];
currentView.decoded = true;
if ([_delegate respondsToSelector:@selector(pictureBrowser:scrollToIndex:)]) {
[_delegate pictureBrowser:self scrollToIndex:index];
}
@@ -253,7 +246,7 @@ - (void)pictureView:(MFPictureView *)pictureView scale:(CGFloat)scale {
self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1 - scale];
}

- (void)pictureView:(MFPictureView *)pictureView image:(UIImage *)image animatedImage:(FLAnimatedImage *)animatedImage didLoadAtIndex:(NSInteger)index {
- (void)pictureView:(MFPictureView *)pictureView image:(UIImage *)image animatedImage:(UIImage *)animatedImage didLoadAtIndex:(NSInteger)index {
if ([_delegate respondsToSelector:@selector(pictureBrowser:image:animatedImage:didLoadAtIndex:)]) {
[_delegate pictureBrowser:self image:image animatedImage:animatedImage didLoadAtIndex:index];
}
@@ -2,7 +2,7 @@
// Copyright © 2018年 GodzzZZZ. All rights reserved.

#import <Foundation/Foundation.h>
#import <FLAnimatedImage/FLAnimatedImage.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, MFImageType) {
MFImageTypeUnknown,
MFImageTypeOther,
@@ -13,5 +13,8 @@ typedef NS_ENUM(NSInteger, MFImageType) {
@property (nonatomic, strong) NSString *imageName;
@property (nonatomic, strong) NSString *imageURL;
@property (nonatomic, assign) MFImageType imageType;
@property (nonatomic, strong) UIImage *placeholderImage;
@property (nonatomic, strong) UIImage *posterImage;
@property (nonatomic, strong) UIImage *animatedImage;
@property (nonatomic, assign, getter = isDecoded) BOOL decoded;
@end
@@ -2,13 +2,12 @@
// Copyright © 2018年 GodzzZZZ. All rights reserved.

#import <UIKit/UIKit.h>
#import <FLAnimatedImage/FLAnimatedImageView.h>
#import "MFPictureModelProtocol.h"
@class MFPictureView;
@protocol MFPictureViewDelegate <NSObject>
- (void)pictureView:(MFPictureView *)pictureView didClickAtIndex:(NSInteger)index;
- (void)pictureView:(MFPictureView *)pictureView scale:(CGFloat)scale;
- (void)pictureView:(MFPictureView *)pictureView image:(UIImage *)image animatedImage:(FLAnimatedImage *)animatedImage didLoadAtIndex:(NSInteger)index;
- (void)pictureView:(MFPictureView *)pictureView image:(UIImage *)image animatedImage:(UIImage *)animatedImage didLoadAtIndex:(NSInteger)index;
@end

@interface MFPictureView : UIScrollView
@@ -19,9 +18,11 @@
// 协议对象
@property (nonatomic, strong) id<MFPictureModelProtocol> pictureModel;
// 当前显示图片的控件
@property (nonatomic, strong, readonly) FLAnimatedImageView *imageView;
@property (nonatomic, strong, readonly) UIImageView *imageView;
// 代理
@property (nonatomic, weak) id<MFPictureViewDelegate> pictureDelegate;
// 解码选项
@property (nonatomic, assign, getter = isDecoded) BOOL decoded;
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithPictureModel:(id<MFPictureModelProtocol>)pictureModel;

Large diffs are not rendered by default.

@@ -0,0 +1,13 @@
//
// UIImage+MFGIF.h
// MFPictureBrowserDemo
//
// Created by 张冬冬 on 2018/4/26.
// Copyright © 2018年 张冬冬. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIImage (MFGIF)
+ (UIImage *)animatedGIFWithData:(NSData *)data;
@end
@@ -0,0 +1,57 @@
//
// UIImage+MFGIF.m
// MFPictureBrowserDemo
//
// Created by 张冬冬 on 2018/4/26.
// Copyright © 2018年 张冬冬. All rights reserved.
//

#import "UIImage+MFGIF.h"
@implementation UIImage (MFGIF)

+ (UIImage *)animatedGIFWithData:(NSData *)data {
if (!data) {
return nil;
}
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
size_t count = CGImageSourceGetCount(source);
UIImage *animatedImage;
if (count <= 1) {
animatedImage = [[UIImage alloc] initWithData:data];
} else {
NSMutableArray <UIImage *> *images = [NSMutableArray array];
NSTimeInterval duration = 0.0f;
for (size_t i = 0; i < count; i++) {
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(source, i, NULL);
duration += [self frameDurationAtIndex:i source:source];
UIImage *image = [UIImage imageWithCGImage:imageRef scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];
[images addObject:image];
CGImageRelease(imageRef);
}
if (!duration) {
duration = (1.0f / 10.0f) * count;
}
animatedImage = [UIImage animatedImageWithImages:images duration:duration];
}
CFRelease(source);
return animatedImage;
}

+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
float frameDuration = 0.1f;
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
NSDictionary <NSString *, NSDictionary *> *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
NSDictionary <NSString *, NSNumber *> *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary];
NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime];
if (delayTimeUnclampedProp) {
frameDuration = [delayTimeUnclampedProp floatValue];
}else {
NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime];
if (delayTimeProp) {
frameDuration = [delayTimeProp floatValue];
}
}
CFRelease(cfFrameProperties);
return frameDuration;
}
@end
@@ -0,0 +1,8 @@

// Copyright © 2018年 GodzzZZZ. All rights reserved.

#import <UIKit/UIKit.h>

@interface UIImageView (TransitionImage)
- (void)animatedTransitionImage:(UIImage *)image;
@end
@@ -0,0 +1,16 @@

// Copyright © 2018年 GodzzZZZ. All rights reserved.

#import "UIImageView+TransitionImage.h"

@implementation UIImageView (TransitionImage)

- (void)animatedTransitionImage:(UIImage *)image {
[UIView transitionWithView:self
duration:0.15f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
self.image = image;
} completion:NULL];
}
@end
@@ -10,7 +10,11 @@ MFPictureModelProtocol
@property (nonatomic, strong) NSString *imageURL;
@property (nonatomic, strong) NSString *imageName;
@property (nonatomic, assign) MFImageType imageType;
@property (nonatomic, strong) UIImage *placeholderImage;
@property (nonatomic, strong) UIImage *posterImage;
@property (nonatomic, strong) UIImage *animatedImage;
@property (nonatomic, assign, getter = isDecoded) BOOL decoded;
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType;
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType posterImage:(UIImage *)posterImage;
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType decode:(BOOL)decode;
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType placeholderImage:(UIImage *)palceholderImage posterImage:(UIImage *)posterImage animatedImage:(UIImage *)animatedImage decoded:(BOOL)decoded;
@end
@@ -4,16 +4,23 @@

@implementation MFPictureModel
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType {
return [self initWithURL:imageURL imageName:imageName imageType:imageType posterImage:[UIImage imageNamed:@"placeholder"]];
return [self initWithURL:imageURL imageName:imageName imageType:imageType placeholderImage:[UIImage imageNamed:@"placeholder"] posterImage:nil animatedImage:nil decoded:true];
}

- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType posterImage:(UIImage *)posterImage {
- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType decode:(BOOL)decode{
return [self initWithURL:imageURL imageName:imageName imageType:imageType placeholderImage:[UIImage imageNamed:@"placeholder"] posterImage:nil animatedImage:nil decoded:decode];
}

- (instancetype)initWithURL:(NSString *)imageURL imageName:(NSString *)imageName imageType:(MFImageType)imageType placeholderImage:(UIImage *)palceholderImage posterImage:(UIImage *)posterImage animatedImage:(UIImage *)animatedImage decoded:(BOOL)decoded {
self = [super init];
if (self) {
_imageURL = imageURL;
_imageName = imageName;
_imageType = imageType;
_placeholderImage = palceholderImage;
_posterImage = posterImage;
_animatedImage = animatedImage;
_decoded = decoded;
}
return self;
}
@@ -7,7 +7,8 @@
#import <PINRemoteImage/PINImageView+PINRemoteImage.h>
#import <PINCache/PINCache.h>
#import <PINRemoteImage/PINRemoteImage.h>
#import "MFPictureBrowser/FLAnimatedImageView+TransitionImage.h"
#import "MFPictureBrowser/UIImageView+TransitionImage.h"
#import "MFPictureBrowser/UIImage+MFGIF.h"
@interface RemoteImageViewController ()
<
UICollectionViewDelegate,
@@ -24,7 +25,6 @@ - (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 10, [UIScreen mainScreen].bounds.size.width - 20, [UIScreen mainScreen].bounds.size.height - 20) collectionViewLayout:flow];

_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.backgroundColor = [UIColor whiteColor];
@@ -50,7 +50,7 @@ - (void)viewDidLoad {

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
// [[[PINRemoteImageManager sharedImageManager] cache] removeAllObjects];
[[[PINRemoteImageManager sharedImageManager] cache] removeAllObjects];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
@@ -69,68 +69,70 @@ - (UICollectionViewCell *)collectionView: (UICollectionView *)collectionView
NSURL *url = [NSURL URLWithString:pictureModel.imageURL];
[cell.displayImageView setPin_updateWithProgress:YES];
__weak MFDisplayPhotoCollectionViewCell *weakCell = cell;

if (pictureModel.imageType == MFImageTypeGIF) {
NSString *cacheKey = [[PINRemoteImageManager sharedImageManager] cacheKeyForURL:url processorKey:nil];
PINCache *cache = [PINRemoteImageManager sharedImageManager].cache;
BOOL imageAvailable = [cache containsObjectForKey:cacheKey];
if (imageAvailable) {
[cache objectForKey:cacheKey block:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) {
FLAnimatedImage *animatedImage = [FLAnimatedImage animatedImageWithGIFData:object];
if (animatedImage) {
pictureModel.posterImage = animatedImage.posterImage;
dispatch_async(dispatch_get_main_queue(), ^{
[weakCell.displayImageView animatedTransitionAnimatedImage:animatedImage];
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_gif_30x30_"];
weakCell.tagImageView.alpha = 1;
});
}
}];
if (pictureModel.animatedImage) {
weakCell.displayImageView.image = pictureModel.animatedImage;
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_gif_30x30_"];
weakCell.tagImageView.alpha = 1;
}else {
[[PINRemoteImageManager sharedImageManager] downloadImageWithURL:url options:(PINRemoteImageManagerDownloadOptionsNone) progressDownload:nil completion:^(PINRemoteImageManagerResult * _Nonnull result) {
if (!result.error && (result.resultType == PINRemoteImageResultTypeDownload || result.resultType == PINRemoteImageResultTypeMemoryCache || result.resultType == PINRemoteImageResultTypeCache)) {
dispatch_async(dispatch_get_main_queue(), ^{
pictureModel.posterImage = result.animatedImage.posterImage;
if (result.requestDuration > 0.25) {
[weakCell.displayImageView animatedTransitionAnimatedImage:result.animatedImage];
} else {
weakCell.displayImageView.animatedImage = result.animatedImage;
}
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_gif_30x30_"];
weakCell.tagImageView.alpha = 1;
});
}
}];
}
}else {
NSString *cacheKey = [[PINRemoteImageManager sharedImageManager] cacheKeyForURL:url processorKey:nil];
PINCache *cache = [PINRemoteImageManager sharedImageManager].cache;
BOOL imageAvailable = [cache containsObjectForKey:cacheKey];
if (imageAvailable) {
[cache objectForKey:cacheKey block:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) {
dispatch_async(dispatch_get_main_queue(), ^{
if ([object isKindOfClass:[NSData class]]) {
[weakCell.displayImageView animatedTransitionImage:[UIImage imageWithData:object]];
}else if ([object isKindOfClass:[UIImage class]]) {
[weakCell.displayImageView animatedTransitionImage:object];
NSString *cacheKey = [[PINRemoteImageManager sharedImageManager] cacheKeyForURL:url processorKey:nil];
PINCache *cache = [PINRemoteImageManager sharedImageManager].cache;
BOOL imageAvailable = [cache containsObjectForKey:cacheKey];
if (imageAvailable) {
[cache objectForKey:cacheKey block:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) {
UIImage *animatedImage = [UIImage animatedGIFWithData:object];
if (animatedImage) {
pictureModel.posterImage = animatedImage.images.firstObject;
pictureModel.animatedImage = animatedImage;
dispatch_async(dispatch_get_main_queue(), ^{
[weakCell.displayImageView animatedTransitionImage:animatedImage];
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_gif_30x30_"];
weakCell.tagImageView.alpha = 1;
});
}
pictureModel.posterImage = weakCell.displayImageView.image;
if (pictureModel.imageType == MFImageTypeLongImage) {
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_long_pic_30x30_"];
weakCell.tagImageView.alpha = 1;
}else {
weakCell.tagImageView.image = nil;
weakCell.tagImageView.alpha = 0;
}];
}else {
[[PINRemoteImageManager sharedImageManager] downloadImageWithURL:url options:(PINRemoteImageManagerDownloadOptionsNone) progressDownload:nil completion:^(PINRemoteImageManagerResult * _Nonnull result) {
if (!result.error && (result.resultType == PINRemoteImageResultTypeDownload || result.resultType == PINRemoteImageResultTypeMemoryCache || result.resultType == PINRemoteImageResultTypeCache)) {
NSData *animatedData = result.animatedImage.data;
UIImage *animatedImage = [UIImage animatedGIFWithData:animatedData];
dispatch_async(dispatch_get_main_queue(), ^{
pictureModel.posterImage = animatedImage.images.firstObject;
pictureModel.animatedImage = animatedImage;
if (result.requestDuration > 0.25) {
[weakCell.displayImageView animatedTransitionImage:animatedImage];
} else {
weakCell.displayImageView.image = animatedImage;
}
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_gif_30x30_"];
weakCell.tagImageView.alpha = 1;
});
}
});
}];
}];
}
}
}else {
if (pictureModel.posterImage) {
weakCell.displayImageView.image = pictureModel.posterImage;
if (pictureModel.imageType == MFImageTypeLongImage) {
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_long_pic_30x30_"];
weakCell.tagImageView.alpha = 1;
}else {
weakCell.tagImageView.image = nil;
weakCell.tagImageView.alpha = 0;
}
}else {
[[PINRemoteImageManager sharedImageManager] downloadImageWithURL:url options:(PINRemoteImageManagerDownloadOptionsNone) progressDownload:nil completion:^(PINRemoteImageManagerResult * _Nonnull result) {
if (!result.error && (result.resultType == PINRemoteImageResultTypeDownload || result.resultType == PINRemoteImageResultTypeMemoryCache || result.resultType == PINRemoteImageResultTypeCache)) {
NSString *cacheKey = [[PINRemoteImageManager sharedImageManager] cacheKeyForURL:url processorKey:nil];
PINCache *cache = [PINRemoteImageManager sharedImageManager].cache;
BOOL imageAvailable = [cache containsObjectForKey:cacheKey];
if (imageAvailable) {
[cache objectForKey:cacheKey block:^(PINCache * _Nonnull cache, NSString * _Nonnull key, id _Nullable object) {
dispatch_async(dispatch_get_main_queue(), ^{
if (result.requestDuration > 0.25) {
[weakCell.displayImageView animatedTransitionImage:result.image];
} else {
weakCell.displayImageView.image = result.image;
if ([object isKindOfClass:[NSData class]]) {
[weakCell.displayImageView animatedTransitionImage:[UIImage imageWithData:object]];
}else if ([object isKindOfClass:[UIImage class]]) {
[weakCell.displayImageView animatedTransitionImage:object];
}
pictureModel.posterImage = weakCell.displayImageView.image;
if (pictureModel.imageType == MFImageTypeLongImage) {
@@ -141,8 +143,28 @@ - (UICollectionViewCell *)collectionView: (UICollectionView *)collectionView
weakCell.tagImageView.alpha = 0;
}
});
}
}];
}];
}else {
[[PINRemoteImageManager sharedImageManager] downloadImageWithURL:url options:(PINRemoteImageManagerDownloadOptionsNone) progressDownload:nil completion:^(PINRemoteImageManagerResult * _Nonnull result) {
if (!result.error && (result.resultType == PINRemoteImageResultTypeDownload || result.resultType == PINRemoteImageResultTypeMemoryCache || result.resultType == PINRemoteImageResultTypeCache)) {
dispatch_async(dispatch_get_main_queue(), ^{
if (result.requestDuration > 0.25) {
[weakCell.displayImageView animatedTransitionImage:result.image];
} else {
weakCell.displayImageView.image = result.image;
}
pictureModel.posterImage = weakCell.displayImageView.image;
if (pictureModel.imageType == MFImageTypeLongImage) {
weakCell.tagImageView.image = [UIImage imageNamed:@"ic_messages_pictype_long_pic_30x30_"];
weakCell.tagImageView.alpha = 1;
}else {
weakCell.tagImageView.image = nil;
weakCell.tagImageView.alpha = 0;
}
});
}
}];
}
}
}

@@ -176,6 +198,8 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
MFPictureBrowser *browser = [[MFPictureBrowser alloc] init];
browser.delegate = self;
MFPictureModel *pictureModel = self.picList[indexPath.row];
pictureModel.decoded = true;
[browser showImageFromView:cell.displayImageView picturesCount:self.picList.count currentPictureIndex:indexPath.row];
}

@@ -190,15 +214,15 @@ - (UIImageView *)pictureBrowser:(MFPictureBrowser *)pictureBrowser imageViewAtIn
return pictureModel;
}

- (void)pictureBrowser:(MFPictureBrowser *)pictureBrowser imageDidLoadAtIndex:(NSInteger)index image:(UIImage *)image animatedImage:(FLAnimatedImage *)animatedImage error:(NSError *)error {
- (void)pictureBrowser:(MFPictureBrowser *)pictureBrowser image:(UIImage *)image animatedImage:(UIImage *)animatedImage didLoadAtIndex:(NSInteger)index {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
MFPictureModel *pictureModel = self.picList[index];
if (animatedImage) {
pictureModel.posterImage = animatedImage.posterImage;
pictureModel.posterImage = animatedImage.images.firstObject;
}else if (image) {
pictureModel.posterImage = image;
}
[self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
// [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
}

@end