【发布时间】:2018-06-14 01:03:18
【问题描述】:
我正在为 iOS 构建一个应用程序,它允许用户基于位置存储图像。
现在我想在 iOS 中使用最新的AnnotationView (MKMarkerAnnotationView),因为它提供了自动集群。
我的问题是,如果未提供此类,则需要 glyphTintColor 将其设置为 UIColor().red。 iOS 正在使用这种颜色为整个图像着色。之后,图像只有这种颜色。
我尝试将glyphTintColor 设置为nil,但这会导致图像变红。我也尝试将其设置为UIColor(red:1.00, green:1.00, blue:1.00, alpha:0.0),但之后图像消失了,您只能看到标记本身。
我希望标记以原始颜色而不是单色显示图像。
谁能帮我解决这个问题?
这是我的完整代码:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let identifier = "PinAnnotationIdentifier"
var pinView = MKMarkerAnnotationView(annotation: annotation, reuseIdentifier: identifier)
pinView?.annotation = annotation
pinView?.clusteringIdentifier = "clusterId"
pinView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
pinView?.canShowCallout = false
pinView?.glyphImage = UIImage(named: "image")
return pinView
}
【问题讨论】:
标签: ios mapkit mkmapview mapkitannotation