如何在UIImageView中复制MKMapView的屏幕?

Rod*_*igo 1 iphone cocoa-touch uikit uiimage ios

我在MKMapView的地图上有一个屏幕.如何将此屏幕复制到图像并像简单的UIImageView一样使用它.

ada*_*ali 5

这可能有用;

UIGraphicsBeginImageContextWithOptions(MKMapView.bounds.size, MKMapView.opaque, 0.0);
[MKMapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)