iPhone MKMapView - MKPolygon Issues

前端 未结 4 1892
南笙
南笙 2020-12-09 21:02

I am trying to plot a MKPolygon on a MKMapView in iOS 4.0. I have an NSArray which contains custom objects that include properties for latitude/longitude. I have a code samp

4条回答
  •  孤城傲影
    2020-12-09 21:29

    For iOS 7.0 and later we should use MKPolygonRenderer instead of MKPolygonView,

    - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id)overlay
    {
       MKPolygonRenderer * polygonView = [[MKPolygonRenderer alloc] initWithPolygon:overlay];
       polygonView.fillColor   = [UIColor greenColor];
       polygonView.strokeColor = [UIColor redColor] ;
       polygonView.lineWidth   = 1.0;
       return polygonView;
    }
    

提交回复
热议问题