我在MKMapview自定义注解视图中工作,并成功地使用以下代码自定义了针脚下降到我自己的图像中。
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *parkingAnnotationIdentifier=@"ParkingAnnotationIdentifier";
if([annotation isKindOfClass:[MyAnnotationClass class]]){
//Try to get an unused annotation, similar to uitableviewcells
MKAnnotationView *annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:parkingAnnotationIdentifier];
//If one isn't available, create a new one
if(!annotationView){
annotationView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:parkingAnnotationIdentifier];
annotationView.image = [UIImage imageNamed:@"my image.png"];
}
return annotationView;
}
return nil;
}也就是说,我为我的图片定制了注释视图的图片,但我需要在注释视图的右上角放置一个气泡或标签,如下所示。
如何做到这一点?你的帮助一定会得到感谢的。

发布于 2015-05-12 19:04:20
MKAnnotationView是从UIView继承过来的。因此您可以向其中添加您自己的子视图。
解决方案:
https://stackoverflow.com/questions/15761972
复制相似问题