在实际开发中需要给View 添加一个背景图
常见的方法有:
1.通过UIImageView
创建一个 UIImageView 让后在View上添加 这个视图(不推荐)
缺点.图片有时候会被拉伸,失真
2.通过view的color
self.view.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"我是背景"]];
这种通过 图片生成color 的方式会消耗很大的内存(也不推荐)
3.通过quarCore(推荐)
UIImage *img = [UIImage imageNamed:@"登录注册背景"];
self.view.layer.contents = (id)img.CGImage;