5

我有一个 calloutDetail 的视图: annotationView.detailCalloutAccessoryView = mapInformationView.view

它工作得很好,但我不想显示标题/副标题,只是我的自定义视图。但是当我将标题/副标题留空时,不会显示标注。

那么,我该如何隐藏它们或只是更改它们的字体大小和名称?

4

1 回答 1

0

隐藏标题(或副标题)标签的一种方法是将MKAnnotation's title(或subtitle)属性设置为nil.

如果您希望标题显示在标记上,而不是标注上,请切换覆盖title的子类中的值。MKAnnotationViewsetSelected(_:animated:)

override func setSelected(_ selected: Bool, animated: Bool) {
    if selected {
        annotation.title = nil
    } else {
        annotation.title = "Title"
    }
    
    super.setSelected(selected, animated: animated)
}
于 2020-09-18T11:36:04.870 回答