截图
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// 1.开始图形上下文
CGSize imageSize = self.view.bounds.size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0.0);
//2.将某个view的所有内容渲染到图形上下文中
CGContextRef contextRef = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:contextRef];
//3.取的图片
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
CGImageRef subImage = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, self.view.bounds.size.width * 0.9, self.view.bounds.size.height));
UIImage * newImage = [UIImage imageWithCGImage:subImage];
//写入本地文件
[UIImagePNGRepresentation(newImage) writeToFile:@"/Users/Lenny/Desktop/view.png" atomically:YES];
//结束图形上下文
UIGraphicsEndImageContext();
}