2016-12-27 83 views
0

我想在引脚位置上方显示UIView,如果用户在地图上移动,UIView应保持在引脚位置上方。我不想使用标注泡泡。有没有其他方法?如何在MKpointAnnotation Pin上方显示UIView

+0

可能会帮助你http://stackoverflow.com/a/38741017/6433023 –

回答

1

iOS中9,我们有一个名为detailCalloutAccessoryView

您可以创建一个视图,并设置为

annotationView.detailCalloutAccessoryView = tempView 

新的属性,请检查网络连接,以获得更多的细节

MapKit iOS 9 detailCalloutAccessoryView usage

0

尝试使用此代码:

func mapView(_ mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView { 
    if (annotation is MKUserLocation) { 
     return nil 
    } 
    else if (annotation is YourAnnotationClassHere) { 
     let identifier = "MyCustomAnnotation" 
     var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) 
     if annotationView { 
      annotationView.annotation = annotation 
     } 
     else { 
      annotationView = MKAnnotationView(annotation, reuseIdentifier: identifier) 
     } 
     annotationView.canShowCallout = false 
     // set to YES if using customized rendition of standard callout; set to NO if creating your own callout from scratch 
     annotationView.image = UIImage(named: "your-image-here.png")! 
     return annotationView 
    } 

    return nil 
} 

这主要是你需要的工作。这是这个答案的一个迅速版本在这里:How to create Custom MKAnnotationView and custom annotation title and subtitle

希望它帮助!

+0

既然你还没有发布任何你的代码,这是我可以帮助你的唯一方法 –