ios UIView转UIImage模糊的问题解决办法
作者:
行走的风车 | 来源:发表于
2016-08-19 09:15 被阅读151次//原有代码 转换后图像模糊
-(UIImage *)getImageFromView:(UIView *)view{
UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
//重写后解决模糊问题
-(UIImage *)getImageFromView:(UIView *)view{
CGSize s = view.bounds.size;
// 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传 NO,否则传YES。第三个参数就是屏幕密度了
UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
本文标题:ios UIView转UIImage模糊的问题解决办法
本文链接:https://www.haomeiwen.com/subject/prkbsttx.html
网友评论