UIImageView的使用
来源:互联网 发布:法学网络课程 编辑:程序博客网 时间:2024/05/25 18:10
UIImageView是继承自UIView的大家都知道
首相先来创建它
第一种创建方式 没参数 直接alloc init
UIImageView *imageView1 = [[UIImageViewalloc]init];
第二种是在创建的时候 就给这个控件一个图片
UIImageView *imageView1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"01"]];
第三种是在创建的时候 给这个控件两张图片一种是普通状态下的 一种是高亮状态下的
UIImageView *imageView1 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"01"] highlightedImage:[UIImage imageNamed:@"02"]];
设置普通状态下的图片 若创建的时候已经给这个imageView普通状态的图片了那么这个图片会覆盖之前的
imageView1.image = [UIImageimageNamed:@"03"];
设置高亮状态下的图片 若创建的时候已经给这个imageView高亮状态的图片了那么这个图片会覆盖之前的
imageView1.highlightedImage =[UIImageimageNamed:@"04"];
让imageView变成高亮状态默认是普通状态
imageView1.highlighted = YES;
设置imageView是否可以和用户交互默认是不可以的
我们通常在添加手势的时候会把这个打开
imageView1.userInteractionEnabled =YES;
默认是空的 如果被设定了颜色,这个颜色就会被应用于和这个imageView任何相关的模块
这个属性是对view的一个染色看官方文档 说的
UIImageRenderingModeAutomatic,
UIImageRenderingModeAlwaysOriginal,
UIImageRenderingModeAlwaysTemplate,
只有这样创建的时候 tintColor才能显示出效果来 而且必须是UIImageRenderingModeAlwaysTemplate平铺状态下才能显示出来
其他两种状态都显示不出来,而且是平铺状态的时候,若不指定颜色,默认是蓝色的
imageView1.image = [[UIImageimageNamed:@"03"]imageWithRenderingMode:UIImageRenderingModeAutomatic];
对这个属性理解的比较浅 求大神指导
imageView1.tintColor = [UIColorredColor];
普通状态下的动画数组
NSArray *normalArray = [NSArrayarrayWithObjects:
[UIImage imageNamed:@"loading_00000"],
[UIImage imageNamed:@"loading_00001"],
[UIImage imageNamed:@"loading_00002"],
[UIImage imageNamed:@"loading_00003"],
[UIImage imageNamed:@"loading_00004"],
[UIImage imageNamed:@"loading_00005"],
[UIImage imageNamed:@"loading_00006"],
[UIImage imageNamed:@"loading_00007"],
[UIImage imageNamed:@"loading_00008"],
[UIImage imageNamed:@"loading_00009"],
[UIImage imageNamed:@"loading_00010"],
[UIImage imageNamed:@"loading_00011"],
[UIImage imageNamed:@"loading_00012"],
[UIImage imageNamed:@"loading_00013"],
nil];
设置在普通状态下 动画的数组
imageView1.animationImages = normalArray;
高亮下的动画数组
NSArray *highArray = [NSArrayarrayWithObjects:
[UIImage imageNamed:@"loading_00013"],
[UIImage imageNamed:@"loading_00012"],
[UIImage imageNamed:@"loading_00011"],
[UIImage imageNamed:@"loading_00010"],
[UIImage imageNamed:@"loading_00009"],
[UIImage imageNamed:@"loading_00008"],
[UIImage imageNamed:@"loading_00007"],
[UIImage imageNamed:@"loading_00006"],
[UIImage imageNamed:@"loading_00005"],
[UIImage imageNamed:@"loading_00004"],
[UIImage imageNamed:@"loading_00003"],
[UIImage imageNamed:@"loading_00002"],
[UIImage imageNamed:@"loading_00001"],
[UIImage imageNamed:@"loading_00000"],
nil];
设置在高亮状态下的动画的数组
imageView1.highlightedAnimationImages = highArray;
设置动画的时间 是按秒算的
默认的时间是每秒三十张图片也就是假如你有10张图片那么默认的时间是10/30秒
imageView1.animationDuration =2;
设置动画重复的次数 默认是无限次的 0就是无限次 默认count =0
imageView1.animationRepeatCount =2;
最后把这个imageView添加上去
_imageView1 = imageView1;
imageView1.frame = CGRectMake(80, 200, 200, 200*400/640);
[self.viewaddSubview:imageView1];
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
这个方法 返回一个bool来判断当前imageView是否在执行动画
if ([_imageView1isAnimating]) {
让imageView停止动画
[_imageView1stopAnimating];
}else{
开始动画从数组的第一张图片开始
[_imageView1startAnimating];
}
}
- UIImageVIew的使用
- UIImageView的使用
- UI UIImageView的使用
- UIImageView的使用
- UIImageView的使用
- iOS UIImageView 的使用
- UIImageView的使用
- UIImageView的使用
- iOS UIImageView的简单使用
- UIImageView 使用图片的用法
- UILabel和UIImageView的使用
- 使用UIImageView的画线方法
- swift中UIImageView的使用
- swift中UIImageView的使用
- ios中UIImageView的使用
- UIImageView 使用
- 使用UIImageView展现来自网络的图片
- 使用UIImageView展现来自网络的图片
- string.IsNullOrEmpty()是什么意思啊
- bzoj1048 分割矩阵 记忆化搜索
- Week4-4Earley Parser
- 结构体对齐
- Android NDK学习之 一. Android NDK简介
- UIImageView的使用
- c语言内存分配
- 在Spring3中,配置DataSource的方法有6种。
- CentOS 7中没有ifconfig命令,而且不能发现eth0
- 趣味i**1/((i-1)**(i-1)) 发现
- 正则表达式判断用户昵称
- (as)Android SDK在线更新镜像服务器
- 二叉树的遍历(无头结点,C语言)——更新后
- 10个不错的编程等宽字体