//http://program.station.ez-net.jp/special/handbook/objective-c/uiview/to-image.asp
// CALayer を利用するにあたって、以下のヘッダーが必要になります。
#import <QuartzCore/QuartzCore.h>
#pragma mark - UIView を UIImage に変換する
+ (UIImage*)imageFromView:(UIView*)view{
UIImage* image;
// UIView のサイズの画像コンテキストを開始します。
UIGraphicsBeginImageContext(view.frame.size);
// 開始した画像コンテキストを取得します。
CGContextRef context = UIGraphicsGetCurrentContext();
// UIView の内容を、開始した画像コンテキストへ書き出させます。
[view.layer renderInContext:context];
// 画像コンテキストから画像を生成します。
image = UIGraphicsGetImageFromCurrentImageContext();
// 画像コンテキストを終了します。
UIGraphicsEndImageContext();
return image;
}
最終更新:2012年09月11日 09:21