如何在 MKAnnotationView 的标注中自定义标题/副标题字体或只是隐藏它们? [英] How can I customize the title/subtitle font in callout from MKAnnotationView or just hide them?

查看:84
本文介绍了如何在 MKAnnotationView 的标注中自定义标题/副标题字体或只是隐藏它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a view to a calloutDetail: annotationView.detailCalloutAccessoryView = mapInformationView.view

它工作正常,但是我不想显示标题/副标题,而只显示我的自定义视图.但是当我将标题/字幕留空时,不会显示标注.

It is working just fine, but I don't want to display a title/subtitle, just my custom view. But when I left title/subtitle empty the callout isn't displayed.

那么,如何隐藏它们或仅更改其字体大小和名称?

So, How can I hide them or just change their font size and name?

推荐答案

隐藏标题(或字幕)标签的一种方法是设置 MKAnnotation title (或字幕)属性设置为 nil .

One way to hide the title (or subtitle) label is to set the MKAnnotation's title (or subtitle) property to nil.

如果您希望标题显示在标记上,而不显示在标注上,请在覆盖 setSelected(_:animated:).

If you want the title to show on the marker, but not on the callout, toggle the title value in a subclass of MKAnnotationView overriding setSelected(_:animated:).

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

这篇关于如何在 MKAnnotationView 的标注中自定义标题/副标题字体或只是隐藏它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆