2

我正在使用带有自定义 placeMark 的 MKMapView,它有一个 NSString 值,我想将它作为标签添加到 mkannotationview 图像中。

- (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(MyPlaceMark *)annotation{

static NSString* AnnotationIdentifier = @"AnnotationIdentifier";

MKAnnotationView* MyView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];

MyView.canShowCallout=YES;
MyView.image = [UIImage imageNamed:@"MyImage.png"];
return MyView;}

这将是获得它的最佳方式,我尝试为图像添加标签,但我遇到了 CGRect 问题,我什么也没得到,不知道如何制作它

谢谢!

4

1 回答 1

4

注释视图绘制图像?在这种情况下,我会添加一个 UILabel 作为子视图。

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];
于 2011-05-30T11:30:56.247 回答