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

2017-01-16  本文已影响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;

}

上一篇下一篇

猜你喜欢

热点阅读