ios 把view生成image, 保持清晰度
pragma mark 生成image
- (UIImage *)makeImageWithView:(UIView *)view
{
CGSize s = view.bounds.size;
// 下面方法左医,第一個參數(shù)表示區(qū)域大小薛夜。第二個參數(shù)表示是否是非透明的宿百。如果需要顯示半透明效果,需要傳NO,否則傳YES。第三個參數(shù)就是屏幕密度了为牍,關鍵就是第三個參數(shù)能颁。
UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}