我有一个 calloutDetail 的视图:
annotationView.detailCalloutAccessoryView = mapInformationView.view
它工作得很好,但我不想显示标题/副标题,只是我的自定义视图。但是当我将标题/副标题留空时,不会显示标注。
那么,我该如何隐藏它们或只是更改它们的字体大小和名称?
我有一个 calloutDetail 的视图:
annotationView.detailCalloutAccessoryView = mapInformationView.view
它工作得很好,但我不想显示标题/副标题,只是我的自定义视图。但是当我将标题/副标题留空时,不会显示标注。
那么,我该如何隐藏它们或只是更改它们的字体大小和名称?
隐藏标题(或副标题)标签的一种方法是将MKAnnotation
's title
(或subtitle
)属性设置为nil
.
如果您希望标题显示在标记上,而不是标注上,请切换覆盖title
的子类中的值。MKAnnotationView
setSelected(_:animated:)
override func setSelected(_ selected: Bool, animated: Bool) {
if selected {
annotation.title = nil
} else {
annotation.title = "Title"
}
super.setSelected(selected, animated: animated)
}