create UIImage from UILabel?
I can use the following code to create image from UIView.
However the same code won't capture the text of UILabel.(it captures label's background color though) How can I create image of UILabel with text?CGSize size = view.bounds.size;
CGContextRef context = CreateARGBBitmapContext(size);
CGContextTranslateCTM(context, 0,开发者_C百科 size.height);
CGContextScaleCTM(context, 1.0, -1.0);
[view.layer renderInContext: context];
CGImageRef imageRef = CGBitmapContextCreateImage(context);
UIImage* img = [UIImage imageWithCGImage: imageRef];
CGImageRelease(imageRef);
CGContextRelease(context);
In the viewcontroller, select the label and on the right side, you should be able to set an image to the label. Also, you might be having a problem with layers... [self addChild: label z:0 tag:1]; Just in case you don't know, z:0 means the layer. So something with z:-1 would be below a picture with z:0. You could just set the text ontop of the label
精彩评论