如何用动画更改mapview上的MKCircle半径?

时间:2016-11-18 02:55:33

标签: ios objective-c animation mkmapview

我想用这样的动画改变圆半径: https://www.youtube.com/watch?v=j0s5DUnEy3k

这是我的代码:

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {

    if (locations != nil) {
        userLocation = locations.firstObject;

        CLLocationDegrees lat = 0.05;
        CLLocationDegrees lon = 0.05;
        MKCoordinateSpan span = MKCoordinateSpanMake(lat, lon);

        CLLocationCoordinate2D location = CLLocationCoordinate2DMake(userLocation.coordinate.latitude, userLocation.coordinate.longitude);

        MKCoordinateRegion region = MKCoordinateRegionMake(location, span);

        [self.myMapView setRegion:region animated:true];

        MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000];
        [self.myMapView addOverlay:circle];
    }
}

我创建了用户的位置注释,并在用户的位置中心添加了一个圆圈

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
{
    MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
    circleView.strokeColor = [UIColor redColor];
    circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.3];
    circleView.lineWidth = 0.2;

    return circleView;
}

并在rendererForOverlay函数

中自定义圆圈

那么,如何用动画改变圆半径?

有人有想法这样做吗?

0 个答案:

没有答案