【发布时间】:2015-10-21 15:01:05
【问题描述】:
我放的是个人形象,而不是传统的红色别针。当我打开地图显示图钉时,图像覆盖了整个地图。是否有图钉图像的最大尺寸,或者我如何在代码中集成某些内容以适应尺寸标准经典图钉?
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let annotationIdentifier = "SomeCustomIdentifier" // use something unique that functionally identifies the type of pin
var annotationView: MKAnnotationView! = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationIdentifier)
if annotationView != nil {
annotationView.annotation = annotation
} else {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
annotationView.image = UIImage(named: "pin maps.png")
annotationView.canShowCallout = true
annotationView.calloutOffset = CGPointMake(-8, 0)
annotationView.autoresizesSubviews = true
annotationView.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView
}
return annotationView
}
【问题讨论】:
标签: ios mapkit swift2 xcode7 mkannotation