Rendering MKMapView to UIImage with real resolution

后端 未结 2 1983
长发绾君心
长发绾君心 2020-12-30 12:53

I am using this function for rendering MKMapView instance into image:

@implementation UIView (Ext)
- (UIImage*) renderToImage
{
  UIGraphicsBeginImageContext         


        
2条回答
  •  旧时难觅i
    2020-12-30 13:33

    Try using UIGraphicsBeginImageContextWithOptions instead of UIGraphicsBeginImageContext:

    UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);
    

    See QA1703 for more details. It says:

    Note: Starting from iOS 4, UIGraphicsBeginImageContextWithOptions allows you to provide with a scale factor. A scale factor of zero sets it to the scale factor of the device's main screen. This enables you to get the sharpest, highest-resolustion snapshot of the display, including a Retina Display.

提交回复
热议问题