iOS——顏色轉圖片

+(UIImage *)imageWithUIColor:(UIColor *)color{it

    CGRect rect=CGRectMake(0.0f, 0.0f, 55.f, 1.f);im

    UIGraphicsBeginImageContext(rect.size);co

    CGContextRef context = UIGraphicsGetCurrentContext();return

    CGContextSetFillColorWithColor(context, [color CGColor]);context

    CGContextFillRect(context, rect);

    UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return theImage;

}

相關文章
相關標籤/搜索