我想在mapView上用自定义图像创建一个标记。是否可以同时显示图像和标题?我试过几种方法
我需要将它们两个都与MKMarkerAnnotationView同时显示,但要有一个自定义的引脚图像。我可以做些什么来实现这一点?
它的工作与自定义类mkAnnotation,我不知道它是最好的做法或没有,但它在我的应用程序中的工作原理。
class SightMap: NSObject, MKAnnotation {
let identifier = "pinImage"
//+ something else, for example
var image: UIImage?
}
///somewhere in your code
let sightmap = SightMap(...init...)
map?.addAnnotation(sightmap)
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let view = MKAnnotationView(annotation: annotation, reuseIdentifier: "pinImage")
view.addSubview(YOUR_IMAGE)
view.addSubview(YOUR_label)
}