MapKit: update MKCircle's blend radius property without flickering

I have MKMapView (self.mapView) to which I add MKCircle overlay (self.radiusOverlay) with a specific radius (self.location.radius).

Right below MKMapView is UISlider (self.radiusSlider), which changes the blending radius to Value Changed:

- (void)viewWillAppear:(BOOL)animated { self.radiusOverlay = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake([self.location.latitude floatValue], [self.location.longitude floatValue]) radius:[self.location.radius floatValue]]; [self.mapView addOverlay:self.radiusOverlay]; self.radiusSlider.value = [self.location.radius floatValue]; } 

This is the method that makes the material for updating the radius:

 - (IBAction)updateLocationRadius:(UISlider *)sender { [self.mapView removeOverlay:self.radiusOverlay]; self.location.radius = [NSNumber numberWithFloat:sender.value]; self.radiusOverlay = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake([self.location.latitude floatValue], [self.location.longitude floatValue]) radius:[self.location.radius floatValue]]; [self.mapView addOverlay:self.radiusOverlay]; } 

This works fine, but doesnโ€™t look good: removing and re-adding self.radiusOverlay, I cause the overlay to flicker.

What can I do to avoid this flicker?

+4
source share

All Articles