我对自定义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
}
编辑: 我只是想在放大或缩小地图时调整注释视图的大小。而当我很远时,烦恼消失了。