1.绘制一张纯色图片
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size alpha:(float)alpha
{
@autoreleasepool {
CGRect rect = CGRectMake(0, 0, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetAlpha(context, alpha);
CGContextSetFillColorWithColor(context,color.CGColor);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
}
2.设置backgroundViewfooter.backgroundView = [[UIImageView alloc]initWithImage:[self imageWithColor:[UIColor whiteColor] size:CGSizeMake(Screen_Width, 100) alpha:1]];