2012-07-11 46 views
-1

我有一個視圖,其中插入了許多文本框和值。現在我想將此視圖保存爲圖片或PDF。保存視圖及其內容爲圖像或pdf

有什麼辦法可以實現這個目標嗎?我使用的IOS 5.1的項目

+2

許多重複的問題在這裏...一:http://stackoverflow.com/questions/3495370/image-from-uiview – 2012-07-11 05:17:25

+0

可能重複[轉換UIImage到PDF文件](http://stackoverflow.com/問題/ 2445335 /轉換-的UIImage - 到 - pdf文件) – CodaFi 2012-07-11 05:23:25

回答

1

你可以把視圖的屏幕截圖,並將其保存:

UIGraphicsBeginImageContext(self.view.frame.size); 
[[self.view layer] renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

現在你擁有了整個觀看內容的一個UIImage,您可以使用它,你喜歡的方式。