![](/img/trans.png)
[英]How do I overlay a circle at a set location using mapkit and swift
[英]How to create a circle overlay over my annotation in Maps using MApkit in iOS?
我想在注释上创建一个圆圈叠加。 我正在使用Swift 3.0。 任何帮助表示赞赏!
尝试自定义叠加层。 在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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.