0

您如何使用 MKPolylines 之类的叠加层获取 MKMapView 的 UIImage?我尝试了 renderInContext 和 MKMapSnapshotter,但都没有在生成的图像中包含地图及其叠加层。renderInContext 在 iOS 7 中根本不起作用。

4

1 回答 1

2

根据MKMapSnapshotter 类的文档,生成的快照中不包含叠加层和注释。根据MKMapSnapshot 类的文档,您可以pointForCoordinate自己手动在快照图像上绘制叠加层和注释。

此外,您可能想发布您的 renderInContext 代码。

- 编辑 -

在 iOS 7 中,他们添加了以下三个新方法,您可能希望与 renderInContext 方法一起尝试:

– snapshotViewAfterScreenUpdates: // Captures view as a snapshot view, which may allow you to draw an image using renderInContet.
– resizableSnapshotViewFromRect:afterScreenUpdates:withCapInsets: // Similar to the previous method, except using a rect.
– drawViewHierarchyInRect:afterScreenUpdates: // Draws the entire view hierarchy, so this may allow you to capture subviews.
于 2013-10-23T20:12:10.923 回答