enter a category UIImage.
eg UIImage(Color)
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size
{
UIGraphicsBeginImageContextWithOptions(size, YES, 0);
[color set];
UIBezierPath * path = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, size.width, size.height)];
[path fill];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext ();
UIGraphicsEndImageContext();
return image;
}
How to use:
#import "UIImage + Color"
UIImage *image = [UIImage imageWithColor:[UIColor redColor] andSize:yourSize];
source
share