2012-09-15 2 views
1

MapView의 오버레이보기 경로를 획으로 채우려 고합니다. 이제 채우기 작품, 뇌졸중 doesnt ... 아래 코드에서 어떤 아이디어?MKMapView - 경로 스트로크

- (void)drawMapRect:(MKMapRect)mapRect 
      zoomScale:(MKZoomScale)zoomScale 
      inContext:(CGContextRef)ctx 
{  
    CGContextSetRGBStrokeColor(ctx, 1.0, 0.0, 0.0, 0.8); 
    CGContextSetRGBFillColor(ctx, 0.0, 0.0, 0.8, 0.4); 

    CGContextSetLineCap(ctx, kCGLineCapRound); 
    CGContextSetLineWidth(ctx, 8.0); 

    CGPoint pt; 
    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(0, 0))]; 
    CGContextMoveToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-2, 3))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-2, 5))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    pt = [self pointForMapPoint:MKMapPointForCoordinate(CLLocationCoordinate2DMake(-4, 4))]; 
    CGContextAddLineToPoint(ctx, pt.x, pt.y); 

    CGContextDrawPath(ctx, kCGPathFillStroke); 
} 

답변

1
이 작동했다

...

CGContextSetLineWidth(ctx, 1 * MKRoadWidthAtZoomScale(zoomScale));