我正在使用此函数将MKMapView实例渲染为图像:
@implementation UIView (Ext)
- (UIImage*) renderToImage
{
UIGraphicsBeginImageContext(self.frame.size);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Run Code Online (Sandbox Code Playgroud)
这很好用.但是使用iphone4时,渲染图像的分辨率与设备上的分辨率不同.在设备上我具有640x920地图视图质量,渲染图像具有320x460的分辨率.然后我将提供给UIGraphicsBeginImageContext()函数的大小加倍,但填充了唯一的左上角图像部分.
问题:有没有办法将地图渲染为具有全分辨率640x920的图像?