首先你必须确保你设置lineWidth
和strokeColor
polylineRenderer.lineWidth = 8.0f;
polylineRenderer.strokeColor = [UIColor redColor];
然后在您的渲染器类中,您必须覆盖-(void) createPath
方法
-(void) createPath{
CGMutablePathRef path = CGPathCreateMutable();
BOOL pathIsEmpty = YES;
for (int i=0;i< polyline.pointCount;i++){
CGPoint point = [self pointForMapPoint:polyline.points[i]];
if (pathIsEmpty){
CGPathMoveToPoint(path, nil, point.x, point.y);
pathIsEmpty = NO;
} else {
CGPathAddLineToPoint(path, nil, point.x, point.y);
}
}
self.path = path; //<—— don't forget this line.
}
如果你想要自定义绘图,你想覆盖这个
-(void) drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
方法。