iOS使用代码截图

/**
* 截图代码
*
* @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;
}
上一篇:三、SQL server 2008数据库的备份与还原


下一篇:CSS3入门之转换