UIColor --> UIImage

2016-07-07  本文已影响45人  温暖的弦Y

#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;

}

上一篇下一篇

猜你喜欢

热点阅读