2014-12-07 41 views
0

我有一个放置在特定变换的视图。我想截取这个视图的截图,但是在渲染之后它没有考虑到变换的价值。转换并截取视图?

我查看

dragView = [[DragbleView alloc] initWithFrame:CGRectMake(10, 200, 200, 90)]; 
dragView.contentView = textField; 
dragView.transform = CGAffineTransformMakeRotation (-0.663247); 
[self.view addSubview:dragView]; 

我的截图代码

UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale); 
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES]; 
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
return image; 

问题After taking screenshot it always comes horizontal neglecting the value of transform

+1

请显示更多代码。你的屏幕截图代码中的“视图”是什么?如何使用图像? – gabbler 2014-12-07 11:46:40

+0

https://github.com/SunnyShah407/DragImageView ..请检查这个项目 – 2014-12-07 12:21:23

+0

因此,你希望视图的变换停留在截图图像中吗? – gabbler 2014-12-07 12:27:56

回答

0

你可以把你想保留的所有子视图的父视图的快照在快照图像中,父视图是self.view。然后保存dragView的变换。

UIImage *mainImage = [self imageWithView:self.view]; 

你忘了在btnSaveClicked功能UIGraphicsEndImageContext()

+0

但这会降低图像的质量。我希望图像的分辨率与以前相同。 – 2014-12-07 16:29:01

+0

您可以使容器视图成为与imageView相同大小的dragView和imageView的超级视图吗?然后快照那个视图?我认为这应该是一种保持图像质量的方法。 – gabbler 2014-12-07 16:32:37

+0

没有图像将来自差异大小1120 * 786 ..没有修复。我无法创建任何容器视图 – 2014-12-07 16:38:01