UIGraphicsBeginImageContext(self.bounds.size );
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *currentScreen = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
这里无法获得更新的暂存器在屏幕截图上完成的截图,但它没有显示在我的屏幕截图中 ![Scratchpad截图] [1]
答案 0 :(得分:0)
如果您考虑截取UIView or UIImageView
。
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 1.0);// Add your view / ScratchPadView whichever you want to take Snap
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
[[UIColor redColor] set];
NSData *imgData = UIImageJPEGRepresentation(image, 1.0);
UIGraphicsEndImageContext();