我正在通过截取 UIView 的屏幕截图来创建 PDF,这目前在具有视网膜显示屏的 iPad3 上运行良好,但是在其他具有较低分辨率屏幕的设备上进行测试时,我遇到了文本分辨率问题。
这是我的代码:
//start a new page with default size and info
//this can be changed later to include extra info.
UIGraphicsBeginPDFPage();
//render the view's layer into an image context
//the last option specifies scale. If 0, it uses the devices scale.
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 2.0);
CGContextRef context = UIGraphicsGetCurrentContext();
[view.layer renderInContext:context];
UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//render the screenshot into the pdf page CGContext
[screenShot drawInRect:view.bounds];
//close the pdf context (saves the pdf to the NSData object)
UIGraphicsEndPDFContext();
我也尝试将UIGraphicsBeginImageContextWithOptions
比例设置为 2.0,但这并没有改变。如何强制 iPad2 上的视图以 2 倍分辨率呈现?
预期输出:
实际输出: