#import <QuartzCore/QuartzCore.h>
添加QuartzCore.framework库
-(void) screenShot
{
UIGraphicsBeginImageContext(self.bounds.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSLog(@"image:%@",image);
UIImageView *imaView = [[UIImageView alloc] initWithImage:image];
imaView.frame = CGRectMake(0, 700, 500, 500);
[self addSubview:imaView];
[imaView release];
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
}
本文转自编程小翁博客园博客,原文链接:http://www.cnblogs.com/wengzilin/archive/2012/05/04/2482947.html,如需转载请自行联系原作者