UIViewの画像をUIImageに変換

UIViewで表示しているイメージをUIImageを作る方法です。を忘れずにインポートして下さい。

#import <QuartzCore/QuartzCore.h>

- (UIImage*)CreateUIImageFromUIView:(UIView*)view
{
    UIGraphicsBeginImageContext(view.bounds.size);
    CGContextScaleCTM(UIGraphicsGetCurrentContext(), 1.0f, 1.0f );
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage* viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return viewImage;
}

参考
UIVIEWからUIIMAGE データを作成する方法

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">