一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。
OC Control FLAnimatedImage(加载GIF动画)下载链接
说明:这个第三方不是本人写的。
效果
使用
#import "FLAnimatedImage.h"
@property (nonatomic,strong) FLAnimatedImageView *flImage;
self.flImage = [FLAnimatedImageView new];
self.flImage.addTo(self.view).borderRadius(5).makeCons(^{
make.center.equal.view(self.view);
make.width.equal.constants(300);
make.height.equal.constants(100);
});
NSData *data1 = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://xxx.xxx.xxx/media/active_page/1ffN9fa1_20190720092942_301.gif"]];
FLAnimatedImage *animatedImage1 = [FLAnimatedImage animatedImageWithGIFData:data1];
self.flImage.animatedImage = animatedImage1;
其实SDWebImage本身自带这个方法的
如果点不出这个方法可能没有导入头文件,或者SDWebImage版本不一样
[self.gifIcon sd_internalSetImageWithURL:[NSURL URLWithString:@"https://xx.xxxx.xxx/media/active_page/1ffN9fa1_20190720092942_301.gif"] placeholderImage:nil options:0 context:nil setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
if (imageData != nil) { [self.gifIcon setImage:[UIImage sd_imageWithGIFData:imageData]]; }
} progress:nil completed:nil];
2022.03.07
记载本地的gif
NSData *localData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"品牌活动" ofType:@"gif"]];
[self.gifIcon setImage:[UIImage sd_imageWithGIFData:localData]];