我正在使用带有自定义 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 方面遇到了问题,我什么也没得到,不知道如何制作它
谢谢!
最佳答案
注释 View 绘制图像?在这种情况下,我将添加一个 UILabel 作为 subview 。
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];
关于objective-c - 在 Mkannotation 图像上添加标签文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6175670/