在MapView注释中更长的字幕(swift)

我有一个显示标题和字幕的注解的地图视图。 字幕有时比注释的宽度长,所以我想知道如果我可以让他们多线? 它是这样编码的:

func annotate(newCoordinate, title: String, subtitle: String) { let annotation = MKPointAnnotation() annotation.coordinate = newCoordinate annotation.title = title annotation.subtitle = subtitle self.map.addAnnotation(annotation) } 

然后我有几个选项设置

 func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {...} 

这里没有关系。

是否可以做一个自定义的注释视图? 我已经尝试了几件事,但没有任何工作。 我能得到的最接近的是添加一个button来分别显示较长的字幕,但我宁愿在注释中。

可能吗?

我想通了,我在viewForAnnotation中添加了一个标签,它只是工作

¯\ _(ツ)_ /¯

 func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { //return nil so map view draws "blue dot" for standard user location return nil } let reuseId = "pin" var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView if pinView == nil { pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId) pinView!.canShowCallout = true } else { pinView!.annotation = annotation } //THIS IS THE GOOD BIT let subtitleView = UILabel() subtitleView.font = subtitleView.font.fontWithSize(12) subtitleView.numberOfLines = 0 subtitleView.text = annotation.subtitle! pinView!.detailCalloutAccessoryView = subtitleView return pinView }