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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM