iOS view截屏

来源:互联网 发布:linux 启动挂载 编辑:程序博客网 时间:2024/06/07 01:40


截取某个view

- (UIImage )viewSnapshot:(UIView )view 


UIGraphicsBeginImageContext(view.bounds.size); 
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect(image.CGImage,view.bounds)]; 
return image; 
}