2010-07-15 89 views

回答

1

試試這個:

UIGraphicsBeginImageContext(map.layer.bounds.size); 
[map.layer renderInContext:UIGraphicxGetCurrentContext()]; 
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

或許你也應該仔細檢查谷歌的許可條款,如果他們能夠製作和分發地圖的截圖。

+0

這裏是最後爲我工作的代碼: CGRect screenRect = [[UIScreen mainScreen] bounds]; \t UIGraphicsBeginImageContext(screenRect.size); \t CGContextRef ctx = UIGraphicsGetCurrentContext(); \t CGContextFillRect(ctx,screenRect); \t [self.view.layer renderInContext:ctx]; \t UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext(); \t UIGraphicsEndImageContext(); \t UIImageWriteToSavedPhotosAlbum(viewImage,self,nil,nil); – MadProfit 2010-07-16 21:50:18

+0

另外,需要添加Quartzcore框架,並在實現文件中使用include Quartzcore。 – MadProfit 2010-07-16 21:52:57

+0

以編程方式,只能將一張照片或圖片附加或嵌入到電子郵件中。 Sorta是有道理的,否則人們可以想象有人會通過程序設計或意外事件造成一些非常大的電子郵件,從而導致iPhone出現一些內存或其他問題。 – MadProfit 2010-07-27 11:20:24