您的位置:首页 > 产品设计 > UI/UE

传入颜色返回图片

2016-06-24 14:24 337 查看
-(UIImage *)imageWithColor:(UIColor *)color {

    CGRect rect =CGRectMake(0.0f,0.0f,
1.0f,1.0f);

    UIGraphicsBeginImageContext(rect.size);

    CGContextRef context =UIGraphicsGetCurrentContext();

    

    CGContextSetFillColorWithColor(context, [colorCGColor]);

    CGContextFillRect(context, rect);

    

    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    

    return image;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息