Initialize a UIImageView object with a rectangle image which will be created by programming
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.
Than开发者_如何学Pythonks in advance,
Sagiftw
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
精彩评论