gpt4 book ai didi

ios - MKOverlayPathRenderer 反转填充区域

转载 作者:行者123 更新时间:2023-11-28 07:56:03 24 4
gpt4 key购买 nike

我在 MKOverlayPathRenderer 中描述了一个多边形区域。我不想填充多边形封闭的区域,而是想填充位于多边形之外的区域。

如何反转 MKOverlayPathRenderer 的填充区域?

这是获取渲染器的函数:

func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = parser.rendererForOverlay(overlay)! as! MKOverlayPathRenderer
renderer.fillColor = UIColor.red
renderer.strokeColor = UIColor.blue
return renderer
}

最佳答案

绘制叠加层时可以使用“interiorPolygons”:

CLLocationCoordinate2D polygoneCoords[10]
= { {Point1LAT,Point1LONG}, {Point2LAT,Point2LONG}, {Point3LAT,Point3LONG}, {Point4LAT,Point4LONG},{Point5LAT,Point5LONG},{Point6LAT,Point6LONG},{Point7LAT,Point7LONG},{Point8LAT,Point8LONG},{Point9LAT,Point9LONG},{Point10LAT,Point10LONG}};
self.myPolygoneArea = [MKPolygon polygonWithCoordinates:polygoneCoords count:10];

CLLocationCoordinate2D worldCoords[6] = { {90, 0}, {90, 180}, {-90,180}, {-90,0}, {-90,-180}, {90,-180} };
myOverlay = [MKPolygon polygonWithCoordinates:worldCoords count:6 interiorPolygons:[NSArray arrayWithObject:myPolygoneArea]];

[self.MyMap addOverlay:myOverlay];

-(MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay{

MKPolygonRenderer *polygon = [[MKPolygonRenderer alloc]initWithOverlay:overlay];

polygon.strokeColor = [UIColor redColor];
polygon.lineWidth = 2;
polygon.fillColor = [[UIColor blackColor]colorWithAlphaComponent:0.3];

return polygon;}

希望这有助于...

关于ios - MKOverlayPathRenderer 反转填充区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48023581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com