作者:pop6959140 | 来源:互联网 | 2023-02-04 16:58
IhavebeentryingtoworkonaapplicationusingtheMapKitandMKPolyline.Ihavegottentheannot
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 it appears that it is moving, sort of like ants along a line I guess is a good analogy.
我一直在尝试使用MapKit和MKPolyline开发一个应用程序。我已经得到了在地图上绘制的注释和路径,但是我正在尝试将lineDashPattern更改为课程方向上的一组动画破折号。我知道lineDashPhase lineDashPattern一起给你一个虚线,并增加lineDashPhase越多,越破折号,然而有办法提高值,这样看来,它是移动,有点像蚂蚁沿着一条线我想是一个很好的类比。
- (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!
这个现在给我虚线。我知道这里也有一个类似的话题,但是我不知道该怎么说。如有任何意见,我们将不胜感激!
1 个解决方案