UI_UIImageView 经常用法
UIImage *image = [UIImage imageNamed:@"bg_2"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(40, 40, 90, 160);
imageView.backgroundColor = [UIColor redColor];
imageView.alpha = 0.5;
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTag = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)];
[imageView addGestureRecognizer:singleTag];
imageView.hidden = NO;
UIImage *netImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"www.google.com"]]];
[self.window addSubview:imageView];
[imageView release];
imageView = nil;
动态图
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.tiff"]];
imageView.frame = CGRectMake(40, 50, 100, 100);
NSMutableArray *array = [NSMutableArray array];
for (int i = 1; i < 5; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.tiff", i]];
[array addObject:image];
}
imageView.animationImages = array;
[self addSubview:imageView];
imageView.animationDuration = 0.4f;
imageView.animationRepeatCount = 0;
[imageView startAnimating];