方法一:
UIView *theMainView =[ [UIView alloc] init];
UIImage *image = [UIImage imageNamed:@"bg.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image] ;
[theMainView addSubview:imageView];
方法二:
[theMainView setBackgroundColor: [UIColor colorWithPatternImage: [UIImage imageNamed: @"bg.png"]]];
imageName 缓存,下面方法不缓存
NSString *thePath = [[NSBundle mainBundle] pathForResource:@"default" ofType:@"jpeg"];
UIImage *prodImg = [[UIImage alloc] initWithContentsOfFile:thePath"];
controller.productImg.image = prodImg;
[prodImg release];