UI_UIImageView
UIImageView用于显示图片的类
相当于一个相框,专门用作显示图片,可以存放一个图片或一组图片
使用initWithImage:方法,创建UIImageView对象
使用initWithContentOfFile:方法,创建一个UIImage对象
UIImageView常用属性
1 {
2 //设置图片
3 image
4 //设置一组动态图片
5 animationImages
6 //设置播放一次一组动态图片的时间
7 animationDuration
8 //设置重复次数
9 animationRepeatCount
10 //开始动画
11 startAnimating
12 //结束动画
13 stopAnimating
1 @implementation ViewController
2
3 - (void)viewDidLoad {
4 [super viewDidLoad];
5 NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:1];
6 for (int i = 10; i < 10; i++) {
7 NSString *fileName = [NSString stringWithFormat:@"lufei_%d.tiff",i];
8 UIImage *aImage = [UIImage imageNamed:fileName];
9 [imageArray addObject:aImage];
10 }
11 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 280, 280)];
12 imageView.animationImages = imageArray;
13 [self.view addSubview:imageView];
14 // 降低播放速度默认时长1.0
15 imageView.animationDuration = 3.0;
16 // 开始播放动画
17 [imageView startAnimating];
18 // Do any additional setup after loading the view, typically from a nib.
2
3 - (void)viewDidLoad {
4 [super viewDidLoad];
5 NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:1];
6 for (int i = 10; i < 10; i++) {
7 NSString *fileName = [NSString stringWithFormat:@"lufei_%d.tiff",i];
8 UIImage *aImage = [UIImage imageNamed:fileName];
9 [imageArray addObject:aImage];
10 }
11 UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 280, 280)];
12 imageView.animationImages = imageArray;
13 [self.view addSubview:imageView];
14 // 降低播放速度默认时长1.0
15 imageView.animationDuration = 3.0;
16 // 开始播放动画
17 [imageView startAnimating];
18 // Do any additional setup after loading the view, typically from a nib.
19 }

浙公网安备 33010602011771号