MapKit:更新 MKCircle 叠加层的半径属性而不闪烁

Pat*_*ick 5 objective-c mapkit

我有一个MKMapView (self.mapView),其中添加了具有特定半径 (self.location.radius) 的MKCircle覆盖 (self.radiusOverlay)。

MKMapView正下方有一个UISlider (self.radiusSlider),它可以在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];
}
Run Code Online (Sandbox Code Playgroud)

这是进行半径更新的方法:

- (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];
}
Run Code Online (Sandbox Code Playgroud)

这工作正常,但看起来不太好:通过删除并重新添加self.radiusOverlay我导致覆盖层闪烁。

我该怎么做才能避免这种闪烁?