iPhone - set MKPolylineView lineDashPattern to be animated
I have been trying to work on a application using the MapKit and MKPolyline. I have gotten the annotations and paths drawn on the map, however I am trying to change the lineDashPattern to be a set of animated dashes in the direction of the course. I know that the lineDashPhase and lineDashPattern together give you a dashed line, and the more you increase lineDashPhase, the more the dashes move, however is there a way to increase the values in such a way that i开发者_Python百科t appears that it is moving, sort of like ants along a line I guess is a good analogy.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
{
MKOverlayView* overlayView = nil;
if(overlay == self.routeLine)
{
//if we have not yet created an overlay view for this overlay, create it now.
if(self.routeLineView == nil)
{
self.routeLineView = [[[MKPolylineView alloc] initWithPolyline:self.routeLine] autorelease];
self.routeLineView.lineWidth = 5;
self.routeLineView.lineDashPhase = 15;
NSArray* array = [NSArray arrayWithObjects:[NSNumber numberWithInt:20], [NSNumber numberWithInt:20], nil];
self.routeLineView.lineDashPattern = array;
}
overlayView = self.routeLineView;
}
return overlayView;
}
This right now give me dashed lines. I know there is a similar topic here, however I am not sure how to go about this. Any input would be greatly appreciated!
I know this is a pretty old question, but I have just implemented a similar solution and posted it here.
精彩评论