iOS,代码截图到相册

下面这段代码可以将当前屏幕显示的内容截图放置相册中,需要导入

#import <QuartzCore/QuartzCore.h>

 

-(void)viewDidAppear:(BOOL)animated

{

    [super viewDidAppear:animated];

    

        self.view.backgroundColor = [UIColorgreenColor];

        UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];

        UIGraphicsBeginImageContext(screenWindow.frame.size);

        [screenWindow.layerrenderInContext:UIGraphicsGetCurrentContext()];

        UIImage * viewImage = UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

    

 

}

 

posted @ 2013-02-14 22:56  X-Code  阅读(1919)  评论(0编辑  收藏  举报