Sto provando a disegnare una linea retta tra due punti nella vista sovrapposizione. Nel metodo MKOverlayView, penso che sto facendo correttamente, ma non capisco il motivo per cui non è disegnare le linee ...non vengono disegnate nella vista sovrapposizione
Qualcuno sa perché?
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale
inContext:(CGContextRef)context
{
UIGraphicsPushContext(context);
MKMapRect theMapRect = [[self overlay] boundingMapRect];
CGRect theRect = [self rectForMapRect:theMapRect];
// Clip the context to the bounding rectangle.
CGContextAddRect(context, theRect);
CGContextClip(context);
CGPoint startP = {theMapRect.origin.x, theMapRect.origin.y};
CGPoint endP = {theMapRect.origin.x + theMapRect.size.width,
theMapRect.origin.y + theMapRect.size.height};
CGContextSetLineWidth(context, 3.0);
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
CGContextBeginPath(context);
CGContextMoveToPoint(context, startP.x, startP.y);
CGContextAddLineToPoint(context, endP.x, endP.y);
CGContextStrokePath(context);
UIGraphicsPopContext();
}
Grazie per il vostro aiuto.
Ha funzionato !! Grazie mille!!! –
Ciao, ho ancora una domanda ... Se devo inizializzare CGPoint da boundingMapRect, come dovrei fare ???? –
oh .. e il motivo per cui non sto utilizzando MkPolylineView è che devo disegnare una freccia non solo in linea retta ... –