【转】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);
}

posted @ 2012-05-04 16:37  编程小翁  阅读(6307)  评论(0)    收藏  举报
我是来自厦门的Jilon. 翁,请关注我的微博:真实的weng,或关注微信:Jilon