1

I use the following code to turn an UIView in an UIImage.

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0f);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Works fine on te simulator. When I check snapshotImage in the console after the breakpoint was hit, it shows the image. Unfortunately, this code doesn't work on a device. It returns a transparent image with the right size. Tested on a iPhone 5 and a iPhone 5S (so no 64-bit problem). Any idea?

yoeriboven
  • 3,541
  • 3
  • 25
  • 40

1 Answers1

1

Turned out it is not possible to first create a snapshot with snapshotViewAfterScreenUpdates: and then turn it into a UIImage. Instead of using the snapshot of self.view I'm using self.view directly now.

Community
  • 1
  • 1
yoeriboven
  • 3,541
  • 3
  • 25
  • 40