美文网首页iOS-OC初级ios
代码生成单色图片

代码生成单色图片

作者: 萝BAIBAI | 来源:发表于2016-03-07 22:55 被阅读41次
- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

相关文章

网友评论

    本文标题:代码生成单色图片

    本文链接:https://www.haomeiwen.com/subject/xaqzkttx.html