iOS图层截图
/** * 方法captureWithView: * * @param view 传入要截图的view * * @return 返回截取的图片 */ + (instancetype)captureWithView:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0); //将view的layer渲染到上下文 [view.layer renderInContext:UIGraphicsGetCurrentContext()]; //取得图像 UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); //关闭上下文 UIGraphicsEndImageContext(); return newImage; }