|
[Objective-C] Capture an image of a view not yet displayed |
|
 |
// Capture an image of a view, inside of a ViewController with Xib, not yet displayed.
// use:
// CaptureViewController *viewController = [[CaptureViewController alloc] initWithNibName:@"CaptureViewController" bundle:nil];
// [viewController loadView];
// UIImage *img = [viewController capture];
//
- (UIImage*)capture {
UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
|
|
|
|
|
|
|
|
Copyright © 1996-2021 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581. |
|
|
|