Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a blank transparent png in Objective-C?

How can I create a blank png UIImage in Objective C programmatically (let's say 36x36 px)?

Thanks :)

like image 659
Nili Avatar asked Sep 02 '12 11:09

Nili


1 Answers

You can open an image context, and then harvest its content immediately, without drawing anything into it. This should produce a blank 36x36 UIImage:

UIGraphicsBeginImageContextWithOptions(CGSizeMake(36, 36), NO, 0.0); UIImage *blank = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 
like image 173
Sergey Kalinichenko Avatar answered Oct 04 '22 11:10

Sergey Kalinichenko