Swift MKAnnotationView图标下的标题
当使用Swift MKAnnotationView图标下的标题,swift,mkannotationview,Swift,Mkannotationview,当使用mkmarkeranotationview进行注释时,标题显示在图标下方,如何在MKAnnotationView中执行此操作 例如: 标题显示在图标下方: annotationView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: identifier) annotationView = MKAnnotationView(annotation: nil, reuseIdentifier: identifier) 标
mkmarkeranotationview
进行注释时,标题显示在图标下方,如何在MKAnnotationView
中执行此操作
例如:
标题显示在图标下方:
annotationView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: identifier)
annotationView = MKAnnotationView(annotation: nil, reuseIdentifier: identifier)
标题不显示在图标下:
annotationView = MKMarkerAnnotationView(annotation: nil, reuseIdentifier: identifier)
annotationView = MKAnnotationView(annotation: nil, reuseIdentifier: identifier)
MKAnnotationView
不会自动执行此操作。您必须自己完成这项工作(例如,有关ObjC示例,请参见)。仅供参考,MKMarkerAnotationView
具有其他自定义行为(当您选择注释时,注释视图会放大,注释的副标题会被查看,等等),因此您必须确定要复制多少自定义行为。但是MKAnnotationView
不会为您做任何事情:您必须自己编写所有代码。我只希望注释图像下有一个标题。另一个问题:是否可以在mkmarkeranotation中更改图像?您可以设置mkmarkeranotationview
的格式。请参阅编辑我的代码。Im给出错误:“MKAnnotationView”类型的值没有成员“glyphImage”是的,您已将annotationView
声明为MKAnnotationView
,因此它不知道mkMarkerNotationView
属性。将其更改为mkmarkernotationview
(并强制转换dequeueReusableAnnotationView
的结果)。