
How to get image color in iPhone SDK application?

- (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size {
//Context
UIGraphicsBeginImageContext(size);
CGContextRef currentContext = UIGraphicsGetCurrentContext();
//size
CGRect fillRect = CGRectMake(0,0,size.width,size.height);
/ color
CGContextSetFillColorWithColor(currentContext, color.CGColor);
//color
CGContextFillRect(currentContext, fillRect);
//Sclose the context
UIImage *retval = UIGraphicsGetImageFromCurrentImageContext(void);
UIGraphicsEndImageContext();
return retval;
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
