1
我試圖爲一個MapView的覆蓋視圖添加筆觸和填充路徑。現在填充工程,筆畫不...從任何想法看下面的代碼?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);
}