xcode – 如何在MKMapView Swift中放大图钉
发布时间:2020-12-14 17:13:35 所属栏目:百科 来源:网络整理
导读:我希望引脚的位置在敲击引脚时放大,以便位置位于中心.我不知道该怎么做.请帮我. 解决方法 你想要做的事情有很多. 确定敲击了哪个引脚 将mapView置于攻丝针上 如果您在项目中正确启动了mapView(以视图作为其委托),则可以使用mapView(_:didSelectAnnotationVie
我希望引脚的位置在敲击引脚时放大,以便位置位于中心.我不知道该怎么做.请帮我.
解决方法
你想要做的事情有很多.
>确定敲击了哪个引脚 如果您在项目中正确启动了mapView(以视图作为其委托),则可以使用mapView(_:didSelectAnnotationView:)方法完成上述两点,如下所示: func mapView(mapView: MKMapView,didSelectAnnotationView view: MKAnnotationView) { // get the particular pin that was tapped let pinToZoomOn = view.annotation // optionally you can set your own boundaries of the zoom let span = MKCoordinateSpanMake(0.5,0.5) // or use the current map zoom and just center the map // let span = mapView.region.span // now move the map let region = MKCoordinateRegion(center: pinToZoomOn!.coordinate,span: span) mapView.setRegion(region,animated: true) } 此方法告诉委托(您的视图最有可能)选择了一个地图注释视图并移动(和/或缩放)到该坐标区域. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |