【发布时间】:2016-06-22 10:09:27
【问题描述】:
我在我的应用程序中使用MKPinAnnotationView。
我将MapView 对象设置为委托,并使用此代码自定义我的AnnotationView
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
//return nil so map view draws "blue dot" for standard user location
return nil
}
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
// pinView!.canShowCallout = true
pinView!.image = UIImage(named:"store.jpg")
pinView!.animatesDrop = true
pinView!.pinTintColor = UIColor.darkGrayColor()
}
else {
pinView!.annotation = annotation
}
return pinView
}
我正在根据需要获取自定义 AnnotationView。但是,我缺少 MKPointAnnotation 的 title 和 subtitle 的功能。
【问题讨论】:
标签: ios swift mkmapview mkannotationview mkpointannotation