美文网首页
根据大小,颜色绘制一张UIImage

根据大小,颜色绘制一张UIImage

作者: 我的马里奥兄弟 | 来源:发表于2017-01-16 11:23 被阅读9次

- (UIImage *)drawTabbarItemBackgroundImageWithSize:(CGSize)size withColorWithRed:(CGFloat)red Green:(CGFloat)green Blue:(CGFloat)blue{

//准备绘图环境

UIGraphicsBeginImageContext(size);

CGContextRef ctx = UIGraphicsGetCurrentContext();

CGContextSetRGBFillColor(ctx, red/255, green/255, blue/255, 1);

CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));

//结束绘图

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;

}

相关文章

网友评论

      本文标题:根据大小,颜色绘制一张UIImage

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