CGRect cutRect = CGRectMake(0, 0, _imageView.frame.size.width, _imageView.frame.size.width); //截图矩形
UIGraphicsBeginImageContextWithOptions(cutRect.size, YES, 0.0); //创建基于当前上下文
[_imageView.layer renderInContext:UIGraphicsGetCurrentContext()]; //渲染,这里是截取imageview显示的图片,如果是截屏则此处是self.view.layer
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); //要释放上下文,否则内存泄露
UIGraphicsBeginImageContextWithOptions(cutRect.size, YES, 0.0); //创建基于当前上下文
[_imageView.layer renderInContext:UIGraphicsGetCurrentContext()]; //渲染,这里是截取imageview显示的图片,如果是截屏则此处是self.view.layer
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); //要释放上下文,否则内存泄露