Domanda

How do you take an UIImage of MKMapView with overlays like MKPolylines? I tried renderInContext and MKMapSnapshotter but none include the map and its overlays in the produced image. renderInContext doesn't work in iOS 7 at all.

È stato utile?

Soluzione

According to the documentation for the MKMapSnapshotter class, overlays and annotations are not included in the produced snapshot. According to the documentation for the MKMapSnapshot class, you can use pointForCoordinate to manually draw the overlays and annotations on the snapshot image yourself.

Also, you might want to post your renderInContext code.

--Edit--

In iOS 7, they added the following three new methods, which you might want to try alongside the renderInContext method:

– 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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top