【问题标题】:How can I customize the title/subtitle font in callout from MKAnnotationView or just hide them?如何在 MKAnnotationView 的标注中自定义标题/副标题字体或隐藏它们?
【发布时间】:2016-02-24 03:33:06
【问题描述】:

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

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

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

【问题讨论】:

  • 您好,您找到解决该问题的方法了吗?
  • 是的,我找到了。我会尽快发布。

标签: swift mapkit title mkannotation callout


【解决方案1】:

隐藏标题(或副标题)标签的一种方法是将MKAnnotationtitle(或subtitle)属性设置为nil

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

override func setSelected(_ selected: Bool, animated: Bool) {
    if selected {
        annotation.title = nil
    } else {
        annotation.title = "Title"
    }
    
    super.setSelected(selected, animated: animated)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-21
    • 2015-07-19
    • 2011-02-24
    • 2023-03-19
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多