ios - 解析gif图片为图片数组
#import <ImageIO/ImageIO.h>
+ (NSArray *)cdi_imagesWithGif:(NSString *)gifNameInBoundle {
NSURL *fileUrl = [[NSBundle mainBundle] URLForResource:gifNameInBoundle withExtension:@"gif"];
CGImageSourceRef gifSource = CGImageSourceCreateWithURL((CFURLRef)fileUrl, NULL);
size_t gifCount = CGImageSourceGetCount(gifSource);
NSMutableArray *frames = [[NSMutableArray alloc]init];
for (size_t i = 0; i< gifCount; i++) {
CGImageRef imageRef = CGImageSourceCreateImageAtIndex(gifSource, i, NULL);
UIImage *image = [UIImage imageWithCGImage:imageRef];
[frames addObject:image];
CGImageRelease(imageRef);
}
return frames;
}
本文标题:ios - 解析gif图片为图片数组
本文链接:https://www.haomeiwen.com/subject/uwpyattx.html
网友评论