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];
时间: 2024-12-28 20:37:18