Objective c 在注释图像上添加Labeltext

Objective c 在注释图像上添加Labeltext,objective-c,mkannotationview,Objective C,Mkannotationview,我正在使用带有自定义placeMark的MKMapView,它有一个NSString值,我想将其作为标签添加到mkannotationview图像中 - (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(MyPlaceMark *)annotation{ static NSString* AnnotationIdentifier = @"AnnotationIdentifier"; MKAnnotation

我正在使用带有自定义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有问题,我没有得到任何东西,任何如何制作它的想法


谢谢

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

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];

是的,注释绘制了图像,我很难找到initWithFrame的x,y,以及image.size属性的宽度和高度。太棒了,我定义了一个上下文,效果很好!谢谢我有一个名为CustomPin的类,它采用了MKAnnotation。我想在注释本身中添加一个数字。我已经为这个类添加了一个UILabel,并计划以这种方式实现它。这样对吗?