2009-10-21 52 views

回答

1

一言以蔽之:

CGImageRef screen = UIGetScreenImage(); 
UIImage *screenImage = [UIImage imageWithCGImage:screen]; 
+1

除此之外,不在API文檔中。 Apple可能不允許在App Store中使用未公開API的應用程序。 – 2009-10-21 09:48:23

11

此代碼添加到您的UIViewController創建其的UIView的屏幕轉儲。

// create screen dump of the view of this view controller 
UIGraphicsBeginImageContext(self.view.bounds.size); 
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

// save image to photos 
UIImageWriteToSavedPhotosAlbum(screenShot, self, nil, nil);