gpt4 book ai didi

ios - 如何向 MKPolylineRenderer 添加阴影或边缘?

转载 作者:行者123 更新时间:2023-11-28 21:51:05 26 4
gpt4 key购买 nike

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

if ([overlay isKindOfClass:[MulticolorPolylineSegment class]]) {
MulticolorPolylineSegment *polyLine = (MulticolorPolylineSegment *)overlay;
MKPolylineRenderer *aRenderer = [[MKPolylineRenderer alloc] initWithPolyline:polyLine];
aRenderer.strokeColor = polyLine.color;
// aRenderer.fillColor = [UIColor redColor];
aRenderer.lineCap = kCGLineCapRound;
aRenderer.lineJoin = kCGLineJoinBevel;
// aRenderer.lineDashPhase = 66;
aRenderer.miterLimit = 40;


aRenderer.lineWidth = 6;



return aRenderer;
}}

代码是在 map 上显示运行的路径,我试了很多方法都不知道怎么解决。

最佳答案

您可以在您的下方添加第二条 MKPolyline。然后你将这个渲染为你的影子。

self.backgroundPolyline = [MKPolyline polylineWithCoordinates:coordinates 
count:count];
self.backgroundPolyline.title = BACKGROUND;
[self.mapView insertOverlay:self.backgroundPolyline
belowOverlay:self.routePolyline];



- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKTileOverlay class]]) {
return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay];
}else if ([overlay isKindOfClass:[MKPolyline class]]) {
MKPolylineRenderer* aView = [[MKPolylineRenderer alloc] initWithPolyline:(MKPolyline*)overlay];
if([overlay.title isEqualToString:BACKGROUND]) {
aView.strokeColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
aView.lineWidth = 8;
}else{
aView.strokeColor = [[UIColor redColor] colorWithAlphaComponent:1];
aView.lineWidth = 2;
}
return aView;
}
return nil;
}

关于ios - 如何向 MKPolylineRenderer 添加阴影或边缘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28308332/

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