【发布时间】:2020-01-31 01:23:36
【问题描述】:
我想将图像添加到 MGLAnnotationView。我使用 Assets.xcassets 文件夹中的图像没有问题,但是当我尝试从图像数组中添加时,我似乎无法弄清楚。
我尝试将“withIdentifier”设置为图像的名称,但没有成功
如果有人可以帮助我,那就太好了!
这是我的代码:
//图像数组
var images: [UIImage] = []
//创建注释图像的函数:
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? {
let annotationImage: MGLAnnotationImage
let annotationImage = mapView.dequeueReusableAnnotationImage(withIdentifier: "camera")
annotationImage = annotationImage ?? MGLAnnotationImage(image: UIImage(named: "camera")!, reuseIdentifier: "camera")
return annotationImage
}
【问题讨论】: