문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top