美文网首页
UIColor --> UIImage

UIColor --> UIImage

作者: 温暖的弦Y | 来源:发表于2016-07-07 16:33 被阅读45次

#pragma mark -- handle image

-(UIImage *)getImageWithAlpha:(CGFloat)alpha{

UIColor *color=[UIColor colorWithRed:1 green:0 blue:0 alpha:alpha];

CGSize colorSize=CGSizeMake(1, 1);

UIGraphicsBeginImageContext(colorSize);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, color.CGColor);

CGContextFillRect(context, CGRectMake(0, 0, 1, 1));

UIImage *img=UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return img;

}

相关文章

网友评论

      本文标题:UIColor --> UIImage

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