控制器view的背景圖片的方法, 四種:spa
1.直接在控制器view上添加一個imageView大小設置的和view同樣對象
UIImageView *beijingimage = [UIImageView alloc]initWithImage:[UIImage imageNamed:@"beijing"];圖片
beijingimage.frame = self.view.frame;it
[self.view addSubview:beijingimage];io
2.重寫控制器view, 直接drawRect畫在上面class
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0);方法
UIImage * image = [UIImage imageNamed:@"beijing"];im
[image drawAsPatternInRect:self.view.bounds];view
3.把image轉換成UIColor對象, 再經過設置背景顏色設置vi
self.view.backgroundColor = [UIColor colorWithPatternImage:@"beijing"];
4.設置layer.contents, 直接設置圖片內容
self.view.layer.contents =[UIImage imageNamed:@"beijing"];