2008-11-17TIPS: UIViewスクリーンショットをライブラリに保存する方法

以下のエントリが役に立った
Topic : (iphone) application screenshot from code?
http://discussions.apple.com/thread.jspa?messageID=8358740
- (IBAction)saveViewToPhotoLibrary:(id)sender {
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil);
UIGraphicsEndImageContext();
}
UIGraphicsBeginImageContext()でキャプチャサイズを指定するのがミソ。
スクリーンショットの保存に成功した後に何か処理を行いたい場合は、UIImageWriteToSavedPhotosAlbum() にセレクタを渡せばOK。



どうもいたしまして(>w<
ありがとうございました.
御役に立ててなによりですw