天天看點

通過UIColor顔色建立UIImage

 CGRect rect = CGRectMake(0, 0, 1, 1);

        UIGraphicsBeginImageContext(rect.size);

        CGContextRef context = UIGraphicsGetCurrentContext();

        CGContextSetFillColorWithColor(context, [[UIColor redColor] CGColor]);

        CGContextFillRect(context, rect);

        UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

繼續閱讀