UIImage *oldImage = [UIImage imageNamed:@"car"]; //舊圖片的尺寸和View不匹配,使用Quartz2D生成新圖片 UIGraphicsBeginImageContextWithOptions(self.view.frame.size, NO, 0.0); [oldImage drawInRect:self.view.bounds]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //將用圖片的顏色來設置View的背景顏色 self.view.backgroundColor = [UIColor colorWithPatternImage:newImage];