UIImageView的使用

本文详细介绍了UIImageView的使用方法,包括初始化UIImageView、设置图片显示位置及模式、动态图片展示、从网络加载图片等内容。

UIImageView 是图片显示控件

View的子类,除了拥有view相同的属性,还有自己特有的属性;


[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. UIImageView *imageview001 = [[UIImageView alloc] initWithFrame:CGRectMake(10.050.060.060.0)];  
  2. [self.view addSubview:imageview001];  
  3. imageview001.image = [UIImage imageNamed:@"newperson"];  


[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. UIImageView *imageview002  = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"newperson"]];  
  2. [self.view addSubview:imageview002];  
  3. imageview002.frame = CGRectMake(10.0120.060.060.0);  
  4.       
  5. // 改变显示内容模式  
  6. imageview002.contentMode = UIViewContentModeCenter;  

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. UIImageView *imageview003 = [[UIImageView alloc] initWithFrame:CGRectMake(0.00.080.080.0)];  
  2. [self.view addSubview:imageview003];  
  3. imageview003.center = self.view.center;  
  4.       
  5. // 动态图片  
  6. NSArray *images = @[[UIImage imageNamed:@"animationsImage01"], [UIImage imageNamed:@"animationsImage02"], [UIImage imageNamed:@"animationsImage03"],[UIImage imageNamed:@"animationsImage04"]];  
  7. imageview003.animationImages = images;  
  8. // 动态时间  
  9. imageview003.animationDuration = 0.5;  
  10. // 动态开始  
  11. [imageview003 startAnimating];  

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. // 网络图标  
  2. NSURL *urlImage = [NSURL URLWithString:@"http://g.hiphotos.baidu.com/zhidao/pic/item/d788d43f8794a4c2936e31c90ef41bd5ac6e3987.jpg"];  
  3. NSData *dataImage = [NSData dataWithContentsOfURL:urlImage];  
  4. UIImage *image = [UIImage imageWithData:dataImage];  
  5. UIImageView *imageview004 = [[UIImageView alloc] initWithFrame:CGRectMake(80.080.0180.0160.0)];  
  6. [self.view addSubview:imageview004];  
  7. imageview004.image = image;      
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值