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 :)


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();