+(UIImage *)captureImageInView:(UIView *)view {
//1.开启上下文
UIGraphicsBeginImageContext(view.frame.size);
//2.绘制图形
CGContextRef ctx = UIGraphicsGetCurrentContext();
//把layer上的内容绘制到上下文当中
[view.layer renderInContext:ctx];
UIImage* newImage =UIGraphicsGetImageFromCurrentImageContext();
//3.关闭上下文
UIGraphicsEndImageContext();
return newImage;
}
网友评论