截屏,然后将图片存入照片库

来源:互联网 发布:奶瓶水滴破解软件下载 编辑:程序博客网 时间:2024/04/27 22:57

1、截屏    //--------通过以上方法 将屏幕信息 截图转成 UIImage对象

- (UIImage *) imageByRenderingView {
 CGFloat oldAlpha = self.alpha;
 
 self.alpha = 1;
 UIGraphicsBeginImageContext(self.bounds.size);
 [self.layer renderInContext:UIGraphicsGetCurrentContext()];
 UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 self.alpha = oldAlpha;
 
 return resultingImage;
}

 

2、存入照片库

UIImage *img = [self imageByRenderingView];

UIImageWriteToSavedPhotosAlbum(img, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

 

//----实现委托 图片保存完成调用--------

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { // Was there an error? if (error != NULL) { // Show error message...   } else // No errors { // Sho
0 0
原创粉丝点击