2011년 3월 10일 목요일

iOS 4.0, Method of replacement UIGetScreenImage function

Method One,

-(UIImage *)captureView:(UIView *)view
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[view.layer renderInContext:ctx];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}

Method Two.

UIGraphicsBeginImageContext(self.view.window.bounds.size);
[self.view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image2 = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image2, nil, nil, nil);

ref: http://cafe.naver.com/mcbugi/71418

댓글 없음:

댓글 쓰기