在iOS中有时候会需要截取mapview当前的显示内容,用来辅助描述你的地理位置,下面的代码为截图的方法:
if (NULL != UIGraphicsBeginImageContextWithOptions)
UIGraphicsBeginImageContextWithOptions(self.mapView.frame.size, NO, 0);
else
UIGraphicsBeginImageContext(self.mapView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.mapView.layer renderInContext:context];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();