一、加一个UIImageview在UIView上(可以)
UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.view.bounds];
imageView.image = [UIImage imageNamed:@"home"];
[self.view addSubview:imageView];
这种方式,原始图片大小不够(小于view的大小),会拉伸图片,让图片失真,view释放后也不会有什么内存保留。
二、通过图片来生成UIColor来设置UIView的背景色。注意是根据图片来生成color(不推荐)
1.imageName方式:
self.view.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"home"]];
2.contentOfFile方式:
NSString *path = [[NSBundle mainBundle]pathForResource:@"name" ofType:@"png"];
self.view.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageWithContents