【发布时间】:2019-12-23 19:49:22
【问题描述】:
我对自定义 MKAnnotationView 的大小有疑问。 我设置了一个自定义图像,但是当 MKMapView 的缩放更改注释的大小时不会。 我失去了注释的默认行为,例如在缩放、调整大小等方面消失。 感谢您的帮助。
我的自定义注释:
class CustomPointAnnotation: MKPointAnnotation {
var pinCustomImageName:String!
var index : Int! }
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
let reuseIdentifier = "pin"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseIdentifier)
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseIdentifier)
annotationView?.canShowCallout = true;
let customPointAnnotation = annotation as! CustomPointAnnotation
var image = UIImage(named: customPointAnnotation.pinCustomImageName)
annotationView?.image = image
annotationView!.isEnabled = true
annotationView!.canShowCallout = true
return annotationView
}
编辑: 我只想在放大或缩小地图时调整注释视图的大小。当我离开时,注解消失了。
【问题讨论】:
-
不清楚你在问什么?放大/缩小时注释不会改变大小。叠加(它们是地球表面上的绘图),但注释没有(它们只是地图标记)。
标签: swift mapkit mkmapview mkannotation mkannotationview