5

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

Right below the MKMapView there is a UISlider (self.radiusSlider) which changes the overlay's radius on 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 which does the radius-updating stuff:

- (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 it's not looking good: By removing and re-adding self.radiusOverlay I cause the overlay to flicker.

What can I do to avoid this flickering?

Patrick
  • 3,091
  • 4
  • 26
  • 29
  • 1
    Try the suggestion in [this answer](http://stackoverflow.com/questions/4876035/mkoverlay-not-resizing-smoothly). Also see the last comment (May 8 at 19:28) on [this answer](http://stackoverflow.com/questions/4759317/moving-mkcircle-in-mkmapview) for another alternative (but more complex). For some more details related to the custom overlay view approach, see [this other answer](http://stackoverflow.com/questions/10529217/is-there-away-to-add-text-using-paths-drawing). –  Jul 04 '12 at 13:59

0 Answers0