MKAnnotationView 缩放图像导致 calloutView 也缩放

MKAnnotationView scaling image causes calloutView to scale as well

所以我有一些公交车站在地图上被标记为注释。我不想使用默认的红色气泡或大头针,而是想使用公交车站牌的图片,所以我成功更改了图片。

这样做时,因为图像是 512x512,所以我决定使用变换缩放 MKAnnotationView。因此,当我 select 一个公共汽车站时,标注气泡现在也缩放到相同的水平,这使得它不可读。

有什么方法可以只缩放图像而不缩放 calloutView?

我的代码:

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
    let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "stopPin")
    annotationView.canShowCallout = true
    annotationView.image = UIImage(named: "busStop.png")
    let transform = CGAffineTransform(scaleX: 0.25, y: 0.25)
    annotationView.transform = transform
    return annotationView
}

使用UIGraphics.

let image = UIImage(named: "busStop.png")
let resizedSize = CGSize(width: 100, height: 100)

UIGraphicsBeginImageContext(resizedSize)
image?.draw(in: CGRect(origin: .zero, size: resizedSize))
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

annotationView?.image = resizedImage