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.
View to image doesn't work on device
Frage
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?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow