开发者

Initialize a UIImageView object with a rectangle image which will be created by programming

开发者 https://www.devze.com 2023-01-08 22:39 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消