I had a similar similar problem in the past. The following steps may work for you as a workaround:
UIGraphicsBeginImageContextWithOptions(editingView.bounds.size, NO, 0.0); [editingView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
Please note that you may lose some accuracy in screen capture, as this may eliminate blurring and some Core Animation features.
Edit:
There seems to be problems / tradeoffs with renderInContext and drawViewHierarchyInRect . The following code may be worth a try (taken from here for reference):
- (CGContextRef) createBitmapContextOfSize:(CGSize) size { CGContextRef context = NULL; CGColorSpaceRef colorSpace; int bitmapByteCount; int bitmapBytesPerRow; bitmapBytesPerRow = (size.width * 4); bitmapByteCount = (bitmapBytesPerRow * size.height); colorSpace = CGColorSpaceCreateDeviceRGB(); if (bitmapData != NULL) { free(bitmapData); } bitmapData = malloc( bitmapByteCount ); if (bitmapData == NULL) { fprintf (stderr, "Memory not allocated!"); return NULL; } context = CGBitmapContextCreate (bitmapData, size.width, size.height, 8,
Then you can do:
CGContextRef context = [self createBitmapContextOfSize:editingView.bounds.size]; [editingView.layer renderInContext:context]; CGImageRef cgImage = CGBitmapContextCreateImage(context); UIImage* background = [UIImage imageWithCGImage: cgImage]; CGImageRelease(cgImage);
source share