// Created by 王聪 on 14/8/25.
-(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应用功能实现——屏幕截图,并将截图保存到用户的相册中。该方法使用了UIKit框架中的UIGraphicsBeginImageContext等API来创建图片上下文环境,然后通过self.layer.renderInContext渲染当前视图到图片上下文中。
1万+

被折叠的 条评论
为什么被折叠?



