UIImageView
来源:互联网 发布:免费球球大作战软件 编辑:程序博客网 时间:2024/06/15 05:19
一. UIImageView加载图片的方式
1.imageNamed: 速度快,占内存,所以适合使用频率高的图片;
2.imageWithContentsOfFile/imageWithData: 适合使用频率低的图片;
参考:http://blog.csdn.net/lvxiangan/article/details/26558267
二.UIImageView的简单动画
方法: imageWithContentsOfFile + animation
demo:
_circleImgV = [[UIImageView alloc]init]; //动画数组 [_circleImgV setAnimationImages:[self getGIFImages]]; _circleImgV.animationDuration = 1.0; [_contentImgV addSubview:circleImgV]; [_circleImgV mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(_contentImgV.centerX); make.centerY.mas_equalTo(_contentImgV.centerY-20); make.size.mas_equalTo(CGSizeMake(frame.size.width-70,frame.size.width-70)); }]; [_circleImgV startAnimating];//启动动画 //[_circleImgV stopAnimating]; //用于停止动画//获取图片数组-(NSArray *)getGIFImages{ NSMutableString * picName = [NSMutableString string]; for (int i = 1; i < 11; i++) { //根据gif图片名而定: [picName appendFormat:@"动画%d#",i]; } NSArray * picNameArr = [picName componentsSeparatedByString:@"#"]; NSMutableArray * imageArr = [NSMutableArray array]; for (int i = 0; i < 10; i++) { //UIImage *img = [UIImage imageNamed:picNameArr[i]]; //imageWithContentsOfFile不能加载image.xcassets中的资源!!! //所以图片必须直接拖到工程目录下 NSString *imgPath = [[NSBundle mainBundle]pathForResource:picNameArr[i] ofType:@"png"]; UIImage *img = [UIImage imageWithContentsOfFile:imgPath]; [imageArr addObject:img]; } return imageArr;}
阅读全文
0 0
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- UIImageView
- 1046. Shortest Distance (20) 单环图的求路径性质
- ActiveMQ(5)-基于ZooKeeper的HA方案
- 集群与分布式的区别
- Apache设置二级域名
- 把自己以前零散的技术学习都移植过来吧,这里编辑文章感觉还不错
- UIImageView
- C语言基础之数组
- 2017年11月25日,技术笔记整理
- 可变参数列表的解析
- Java —— 包装类
- Spring配置文件<context:property-placeholder>标签使用漫谈
- C# CountdownEvent实现
- 工程师的调试法宝之Segger RTT使用
- 再见