views:

16

answers:

1

Hi,

I want to create a UIImageView object and initialize it with a rectangle image that will be created by programming and NOT from a pre-created bitmap file.

Thanks in advance,

Sagiftw

+1  A: 

To create a rectangle filled with blue:

CGRect imageRect = CGRectMake(0, 0, <#CGFloat width#>, <#CGFloat height#>);
UIGraphicsBeginImageContext(imageRect.size);
[[UIColor blueColor] set];
UIRectFill(imageRect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// now do something with image
jtbandes