1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| -(void) drawRect:(CGRect) rect
{
CSRouteAnnotation* routeAnnotation = (CSRouteAnnotation*)self.routeView.annotation;
if(!self.hidden && nil != routeAnnotation.routes)
{
CGContextRef context = UIGraphicsGetCurrentContext();
if(nil == routeAnnotation.lineColor)
routeAnnotation.lineColor = [UIColor blueColor];
CGContextSetStrokeColorWithColor(context, routeAnnotation.lineColor.CGColor);
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextSetLineWidth(context, 4.0);
for(int idR = 0; idR < routeAnnotation.routes.count; idR++){
NSMutableArray * lespoints = [routeAnnotation.routes objectAtIndex:idR];
for(int idx = 0; idx < lespoints.count; idx++)
{
CLLocation* location = [lespoints objectAtIndex:idx];
CGPoint point = [self.routeView.mapView convertCoordinate:location.coordinate toPointToView:self];
if(idx == 0)
{
CGContextMoveToPoint(context, point.x, point.y);
}
else
{
CGContextAddLineToPoint(context, point.x, point.y);
}
}
}
CGContextStrokePath(context);
} |
Partager