我正在展示一個按鈕的彈出式窗口,用戶可以在彈出窗口中繪製一個圖形。我想以UIImage的形式捕捉這幅圖畫。如何從popover的內容製作UIImage(截圖)?
目前的圖紙是一個簡單的線條使用UIBezierPath,類似於本教程繪製:http://soulwithmobiletechnology.blogspot.com/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html
在此先感謝您的幫助!
我正在展示一個按鈕的彈出式窗口,用戶可以在彈出窗口中繪製一個圖形。我想以UIImage的形式捕捉這幅圖畫。如何從popover的內容製作UIImage(截圖)?
目前的圖紙是一個簡單的線條使用UIBezierPath,類似於本教程繪製:http://soulwithmobiletechnology.blogspot.com/2011/05/uibezierpath-tutorial-for-iphone-sdk-40.html
在此先感謝您的幫助!
如果有其他人遇到此問題。如果你不能找到renderInContext只是 #import <QuartzCore/QuartzCore.h>
的實際拷貝粘貼的解決方案:
#import <QuartzCore/QuartzCore.h>
- (UIImage*) screenShot {
UIGraphicsBeginImageContext(_view.bounds.size);
[_view.layer renderInContext: UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); //renders view to an image
UIGraphicsEndImageContext();
return viewImage;
}
http://stackoverflow.com/questions/1112947/how-to-create-a-uiimage-from -the-current-graphics-context – NeverBe 2012-02-18 13:00:43
謝謝!我得到了它的工作。我找不到renderInContext,需要添加導入#import。這篇文章引導我朝着正確的方向前進 –
naudec
2012-02-19 08:04:26