0

我想在注释上创建一个圆形叠加层。我正在使用 swift 3.0。任何帮助表示赞赏!

4

1 回答 1

1

尝试自定义叠加层。将其添加到viewDidLoad

MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000];
[map addOverlay:circle];

userLocation可以通过将 存储MKUserLocationAnnotation为属性来获得。然后,要实际绘制圆圈,请将其放入地图视图的委托中:

- (MKOverlayRenderer *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{
    MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
    circleView.strokeColor = [UIColor redColor];
    circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4];
    return circleView;
}
于 2017-02-18T18:21:59.137 回答