使用該方法不會(huì)模糊,根據(jù)屏幕密度計(jì)算
//使用該方法不會(huì)模糊链瓦,根據(jù)屏幕密度計(jì)算
- (UIImage *)convertViewToImage:(UIView *)view {
UIImage *imageRet = [[UIImage alloc]init];
//UIGraphicsBeginImageContextWithOptions(區(qū)域大小, 是否是非透明的, 屏幕密度);
UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, [UIScreen mainScreen].scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
imageRet = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return imageRet;
}
這個(gè)方法轉(zhuǎn)換出來的圖片 文字圖片會(huì)變模糊
//這個(gè)方法轉(zhuǎn)換出來的圖片 文字圖片會(huì)變模糊
- (UIImage *)convertViewToImage2:(UIView *)view {
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}