截图
- (void)saveToPhone:(id)sender{
UIGraphicsBeginImageContext(_qrView.bgView.bounds.size);
[_qrView.bgView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image= UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imaView = [[UIImageView alloc] initWithImage:image];
imaView.frame = _qrView.frame;
//保存到相册
UIImageWriteToSavedPhotosAlbum(image, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
}
- (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
NSString *message = nil;
if (!error) {
message = @"成功保存到相册";
}else
{
message = [error description];
}
}
这样保存的图片严重发虚,找到解决方法:
那么首先去搜索下 在你的代码里面有没有遇到
用 UIGraphicsBeginImageContext(<#CGSize size#>) 这个方法。
如果有那么 截屏的图片肯定是模糊的,因为在iOS7 的分辨率 会改为另外一种代替的方法
就是它
UIGraphicsBeginImageContextWithOptions(<#CGSize size#>, <#BOOL opaque#>, <#CGFloat scale#>)
瞬间图片变清晰了~~
附上多个截屏方法,是否有用待以后求证:http://www.cnblogs.com/pengyingh/articles/2466955.html
转载于:https://my.oschina.net/yup/blog/657841