I'm taking the screenshot following way.
- (UIImage*)screenshot
{
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect rect = [keyWindow bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
On UIView I'm drawing paths using UIBezierPath
.
The screenshots that I'm getting are incorrect like this
Any ideas why the upper part is cut to blank ? On UIView all drawing is displayed correctly.
UPDATE : This happens when I draw a long path with UIBezierPath
when I release the my brush and get the screenshot it gets the screenshot correctly.
I saw the another thread which you post. According to the apple technical Q&A, you need to adjust the geometry coordinate first. So, before render the layer of window, do following things first.
Use This one