
I am drawing MKPolyLine over MKMapView. Before iOS 10 is was working fine. In iOS 10 its showing color patches other than routes.
 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay
 {
 [![enter image description here][1]][1]if ([overlay isKindOfClass:[MKPolyline class]]) {
    MKPolyline *route = overlay;
    @try {
        MKPolylineRenderer *routeRenderer = [[MKPolylineRenderer alloc] initWithPolyline:route];
        routeRenderer.strokeColor = [UIColor colorWithRed:20/255.0 green:153/255.0 blue:255/255.0 alpha:1.0];
        routeRenderer.lineWidth = 3;
        [routeRenderer setNeedsDisplay];
        return routeRenderer;
    }
    @catch (NSException *exception) {
        NSLog(@"exception :%@",exception.debugDescription);
    }
}
else return nil;
}
Its look like iOS 10 bug, I spend lot of time to "hack" this bug.
I found only one solution when I redraw MKPolyline(remove old and add new) it should be call it in dispatch_after, it look like it should be redraw when map make shape. (imho)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        // Add MKPolyline to mapView
});
I too redraw MKPolyline when mapView delegate call
- (void)mapViewDidFinishRenderingMap:(MKMapView *)mapView fullyRendered:(BOOL)fullyRendered
It is required more tests but it look it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With