Display MKMapViewAnnotations within a map view's visible rect

后端 未结 7 730
梦毁少年i
梦毁少年i 2021-02-02 02:31

I\'m displaying an MKMapView inside a Path-style parallax table view header. To create the effect, the mapView bounds is larger than the area visible to the user. I need to set

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-02 03:07

    Starting from iOS 7.0, this can be easily achieved with showAnnotations.

    Swift:

    mapView.showAnnotations(mapView.annotations, animated: true)
    

    Objective-C:

    [mapView showAnnotations:mapView.annotations animated:YES];
    

    The above statement will adjust the map view's visible rect in order to display all annotations.

提交回复
热议问题