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

时间:2012-04-23 03:20:04

标签: iphone ios cocoa-touch uikit uiimage

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

1 个答案:

答案 0 :(得分:5)

这可能有用;

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