/**
* 截图代码
*
* @param view 需要截图的view
* @param rect 需要截取的区域
*
* @return 返回截取的对象
*/
+ (UIImage *)viewSnapshot:(UIView *)view withInRect:(CGRect)rect
{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage,rect);
image = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
return image;
}