[OC]显示动态图片
前期准备自己看上一篇👆👆👆
直接上代码:
//UIImageView
NSMutableArray *imgArray = [NSMutableArray array];
for (int i=0; i<15; i++) {
if (i<10) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"testGIF000%d",i]];
[imgArray addObject:image];
}else{
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"testGIF00%d.png",i]];
[imgArray addObject:image];
}
_imageView.animationImages = imgArray;
_imageView.animationRepeatCount = 100;
_imageView.animationDuration = 16*0.15;
[_imageView startAnimating];
}
//UIWebView
NSString *path = [[NSBundle mainBundle] pathForResource:@"testGIF" ofType:@"gif"];
NSData *gifData = [NSData dataWithContentsOfFile:path];
_webView.userInteractionEnabled = NO;
[_webView loadData:gifData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];

浙公网安备 33010602011771号