IOS 由RGB、UIColor生成UIImage

来源:互联网 发布:单片机产生正弦波程序 编辑:程序博客网 时间:2024/06/05 06:25

- (UIImage *)ImageWithColor: (UIColor *) color frame:(CGRect)aFrame

{

    aFrame = CGRectMake(0,0, aFrame.size.width, aFrame.size.height);

    UIGraphicsBeginImageContext(aFrame.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [colorCGColor]);

    CGContextFillRect(context, aFrame);

    

    UIImage *theImage =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return theImage;

}

0 0
原创粉丝点击