UIImageView 是图片显示控件
是View的子类,除了拥有view相同的属性,还有自己特有的属性;
- UIImageView *imageview001 = [[UIImageView alloc] initWithFrame:CGRectMake(10.0, 50.0, 60.0, 60.0)];
- [self.view addSubview:imageview001];
- imageview001.image = [UIImage imageNamed:@"newperson"];
- UIImageView *imageview002 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"newperson"]];
- [self.view addSubview:imageview002];
- imageview002.frame = CGRectMake(10.0, 120.0, 60.0, 60.0);
- // 改变显示内容模式
- imageview002.contentMode = UIViewContentModeCenter;
- UIImageView *imageview003 = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 80.0, 80.0)];
- [self.view addSubview:imageview003];
- imageview003.center = self.view.center;
- // 动态图片
- NSArray *images = @[[UIImage imageNamed:@"animationsImage01"], [UIImage imageNamed:@"animationsImage02"], [UIImage imageNamed:@"animationsImage03"],[UIImage imageNamed:@"animationsImage04"]];
- imageview003.animationImages = images;
- // 动态时间
- imageview003.animationDuration = 0.5;
- // 动态开始
- [imageview003 startAnimating];
- // 网络图标
- NSURL *urlImage = [NSURL URLWithString:@"http://g.hiphotos.baidu.com/zhidao/pic/item/d788d43f8794a4c2936e31c90ef41bd5ac6e3987.jpg"];
- NSData *dataImage = [NSData dataWithContentsOfURL:urlImage];
- UIImage *image = [UIImage imageWithData:dataImage];
- UIImageView *imageview004 = [[UIImageView alloc] initWithFrame:CGRectMake(80.0, 80.0, 180.0, 160.0)];
- [self.view addSubview:imageview004];
- imageview004.image = image;
本文详细介绍了UIImageView的使用方法,包括初始化UIImageView、设置图片显示位置及模式、动态图片展示、从网络加载图片等内容。
1286

被折叠的 条评论
为什么被折叠?



