MapKit: rendering MKCircle with unwanted artifacts

I use MKCircle to display the user's location in MKMapView. This is done with a few lines of code:

MKCircle creature:

self.mapCircle = MKCircle(center: pinLocation, radius: 50)
self.mapView.add(self.mapCircle!)

Rendering using MKMapViewDelegate:

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        guard let circle = overlay as? MKCircle else { return MKOverlayRenderer(overlay: overlay) }

        let renderer = MKCircleRenderer(circle: circle)

        renderer.strokeColor = .red
        renderer.lineWidth = 1

        return renderer
}

It behaves pretty well until I zoom out and go back. Then I get an artifact of a vertical line that appears in the same place all the time. It does not depend on the stroke width.

my annoying impact artifact

Does anyone know of any solution to avoid this artifact?

+4
source share

Source: https://habr.com/ru/post/1674231/


All Articles