小编Ric*_*oli的帖子

大小图像引脚注释

我把个人形象改为传统的红色别针.当我打开地图以显示图钉时,图像会覆盖整个地图.是否有最大尺寸的引脚图像或如何在代码中集成某些东西以适应尺寸标准的经典引脚?

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
}
Run Code Online (Sandbox Code Playgroud)

mapkit mkannotation ios xcode7 swift2

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×1

mapkit ×1

mkannotation ×1

swift2 ×1

xcode7 ×1