2014-12-07 42 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