使用颜色当图片

来源:互联网 发布:图书管理系统java项目 编辑:程序博客网 时间:2024/04/30 09:14

大部分是用来设置UIButton 的backgroundImage

- (UIImage*)buttonImageFromColor:(UIColor*)color{    CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);    UIGraphicsBeginImageContext(rect.size);    CGContextRef context = UIGraphicsGetCurrentContext();    CGContextSetFillColorWithColor(context, [color CGColor]);    CGContextFillRect(context, rect);    UIImage* img = UIGraphicsGetImageFromCurrentImageContext();    UIGraphicsEndImageContext();    return img;}
0 0
原创粉丝点击