是否可以更改blue dot https://i.stack.imgur.com/ELWID.jpg这表明用户的位置MKMapView
到图像?例如一辆小汽车或任何.png
image?
In the 查看注释:的方法MKMapViewDelegate也许你会有这样的代码。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapView.userLocation) return nil;
...
我们回来nil if the 注解 is 用户位置让mapView显示蓝点和圆圈动画。为了显示我们的自定义注释用户位置只需删除该行return nil;
并在那里进行定制。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString* AnnotationIdentifier = @"Annotation";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if (!pinView) {
MKPinAnnotationView *customPinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
if (annotation == mapView.userLocation){
customPinView.image = [UIImage imageNamed:@"myCarImage.png"];
}
else{
customPinView.image = [UIImage imageNamed:@"mySomeOtherImage.png"];
}
customPinView.animatesDrop = NO;
customPinView.canShowCallout = YES;
return customPinView;
} else {
pinView.annotation = annotation;
}
return pinView;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)