为MKMapAnnotation中的自定义图像获取阴影,类似于在Swift中的MKPinAnnotation中的阴影

时间:2019-01-28 19:24:26

标签: ios swift mapkit mkannotationview mkpinannotationview

当您将带有MKPinAnnotation的图钉放到地图上时,除了红色的小图钉外,地图上还会显示阴影,使图钉看起来更有趣。

代码:

 let annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "annotation")

enter image description here

为了显示注释视图的自定义图像,我用可以自定义的MKAnnotationView替换了为您提供阴影的MKPinAnnotation:

代码:

let annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "annotation")
annotationView.image = UIImage(named: "myMarker.png")

但是,我不再有阴影。

enter image description here

有什么方法可以使用MKAnnotationView来显示类似于MKPinAnnotationView的阴影,而不会疯狂地每次从头开始创建阴影吗?

0 个答案:

没有答案