Archive
Posts Tagged ‘UIGraphicsGetImageFromCurrentImageContext’
Getting a Screencapture of UIView
August 22, 2011
Leave a comment
Some times you have to capture a portion of you iPhone application programmatically;
The quickest way is to pass the target view to following method and get its screenshot as an UIImage;
-(UIImage*)captureFullScreen:(UIView*) targetView{
UIGraphicsBeginImageContext(targetView.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *fullScreenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(fullScreenshot, nil, nil, nil);
return fullScreenshot;
}

Recent Comments