本文介绍了在Mkannotation图像上添加Labeltext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有自定义placeMark的MKMapView,它具有NSString值,我想将其作为标签添加到mkannotationview图像中.
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;}
哪一种是最好的获取方式,我试图在图像上添加标签,但是CGRect出现问题,却一无所获,不知道如何制作
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
谢谢!
推荐答案
注释视图绘制图像?在这种情况下,我将添加UILabel作为子视图.
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];
这篇关于在Mkannotation图像上添加Labeltext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!