如何获取 MKMarkerAnnotationView 图像?

ali*_*ego 5 xcode mkannotationview ios swift

我使用 MKMapSnapshotter 创建了地图图像。不幸的是,快照器不允许您添加注释,因此我想将注释直接添加到视图上。

我知道对于引脚,您可以执行以下操作来获取引脚的 UIImage:

let pinView = MKPinAnnotationView(annotation: nil, reuseIdentifier: nil)
let pinImage = pinView.image
Run Code Online (Sandbox Code Playgroud)

这很好用。不过我想要标记的图像。我已尝试以下操作,但不幸的是没有出现任何内容。

let markerView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: nil)
let markerImage = markerView.image
Run Code Online (Sandbox Code Playgroud)

我已将图像更改为 glyphImage ,没有区别。有没有办法获取标记图像?