#import
<QuartzCore/QuartzCore.h>
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
本文介绍了一种使用Objective-C捕获当前屏幕的方法,并演示了如何创建一个全黑的图片。通过设置屏幕上下文、填充黑色背景以及利用视图层渲染到上下文中,最终从上下文中获取图像。
1382

被折叠的 条评论
为什么被折叠?



