IOS中截屏的实现,很简易的方法

#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);
}

你可能感兴趣的:(ios)