I have a UIView and I want it to be stored as a transparent PNG, i.e. without the UIVIew background color...
I am currently using this code and it's working OK but with the background color :(
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* image1 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imageData = UIImagePNGRepresentation(image1);
[imageData writeToFile:filePath atomically:YES];
So does anyone have any idea about getting this image as a transparent one?
Thank you in advance..
In my case, I forgot the opaque property. It should be set to NO:
view.opaque = NO;