我在 MapKit 上使用自定义标记
如何更改自定义标记上的图像宽度和高度?
我的代码:
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if (annotation is MKUserLocation) {
return nil
}
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView.image = UIImage(named:"x2.png")
anView.canShowCallout = true
}
else {
anView.annotation = annotation
}
return anView
}
最佳答案
尝试使用
anView.frame.size = CGSize(width: 30.0, height: 30.0)
关于ios - swift 上的自定义标记图像(MapKit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30262269/