如何改变UITableViewHeaderFooterView的背景颜色

来源:互联网 发布:特斯拉软件如何升级 编辑:程序博客网 时间:2024/06/06 13:13

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.设置backgroundView

footer.backgroundView = [[UIImageViewalloc]initWithImage:[selfimageWithColor:[UIColorwhiteColor] size:CGSizeMake(Screen_Width,100) alpha:1]];


0 0
原创粉丝点击