截图整个页面
若是要用类方法,则封装成一个类里面,到时候导入头文件,直接就可以用类来调用;
- (UIImage *)getScreenImageWithView:(UIView *)view {
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
iOS将View的内容转变为Image
//将UIView转成UIImage
-(UIImage *)getImageFromView:(UIView *)theView
{
//UIGraphicsBeginImageContext(theView.bounds.size);
UIGraphicsBeginImageContextWithOptions(theView.bounds.size, YES, theView.layer.contentsScale);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}