iOS_UIImge_Gif的展示
2016-12-06 16:45
323 查看
github地址: https://github.com/mancongiOS/UIImage.git
方式一: 用动画展示
方式二:用UIWebView展示
其中的HTML文件
方式一: 用动画展示
UIImageView *gifImageView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; gifImageView.backgroundColor = [UIColor orangeColor]; NSArray *gifArray = [NSArray arrayWithObjects: [UIImage imageNamed:@"1.png"], [UIImage imageNamed:@"2.png"], [UIImage imageNamed:@"3.png"], [UIImage imageNamed:@"4.png"], [UIImage imageNamed:@"5.png"], [UIImage imageNamed:@"6.png"], [UIImage imageNamed:@"7.png"], [UIImage imageNamed:@"8.png"], nil]; gifImageView.animationImages = gifArray; //动画图片数组 gifImageView.animationDuration = 5; //执行一次完整动画所需的时长 gifImageView.animationRepeatCount = MAXFLOAT; //动画重复次数 [gifImageView startAnimating]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // [gifImageView stopAnimating]; }); [self.view addSubview:gifImageView];
方式二:用UIWebView展示
UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -44, self.view.bounds.size.width, self.view.bounds.size.height + 44)]; webView.userInteractionEnabled = NO; webView.backgroundColor = [UIColor redColor]; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; [webView loadHTMLString:htmlCont baseURL:baseURL]; [self.view addSubview:webView];
其中的HTML文件
<!DOCTYPE html> <html> <head> </head> <body> <IMG src="gif.gif" border=0 width="100%" height="100%"> </body> </html>
相关文章推荐
- tegra K1 安装GUVcview出现“cannot locate cpu MHZ in/proc/cpuinfo”
- iOS_UIImage_jpg<-->png转换
- iOS_UIImage_给图片添加水印
- Vue.js2.0从入门到放弃---入门实例(三)
- 看完这篇让你对各种前端build工具不再懵逼!
- iOS_UIImage_裁切圆形头像
- angular-cli安装及build项目
- ZooKeeper实现分布式队列Queue
- iOS_UIImage_图片剪切
- 深入 AngularUI Router
- top: /proc is not mounted, required for output data 的解解决方法
- (Uva)Buy or Build(B)
- POJ2926-Requirements,曼哈顿距离。去掉绝对值符号暴力枚举所有情况,神薙!
- iOS_UIImage_图片旋转
- 归纳笔记010:UICollectionView
- 归纳笔记09:UITableView
- 关于Autolayout适配4S的比较好的方案
- 给图集中个头像加上一个圆形遮罩
- druid连接derby数据库报错的问题——2016.12.06
- make: execvp: /usr/local/cuda: 权限不够 Makefile:588: recipe for target '.build_release/cuda/src/caffe/l