问题
I am using a MKMapView with custom placeMark, it has a NSString value and i'll like to add it as label to the mkannotationview image.
- (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;}
Which would be the best way to get it, I tried to add a label to the image but I had problems with the CGRect and I get nothing, any idea how to make it
Thanks!
回答1:
The annotation view draws the image? In that case I would add a UILabel as a subview.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];
来源:https://stackoverflow.com/questions/6175670/add-labeltext-on-mkannotation-image