I have a custom UILabel with round corners and a shadow. I use properties on CALayer to achieve this. Then I try to save this as a UIImage using renderInContext :. Round corners are supported, but a black background appears and the shadow is lost.

Any thoughts on rendering UILabel as an image, but keeping shadow and rounded corners?
Here is the code I use to render the label:
UIGraphicsBeginImageContextWithOptions(label.bounds.size, YES, 0);
[label.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
source
share