首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >在Mkannotation图像上添加标签文本

在Mkannotation图像上添加标签文本
EN

Stack Overflow用户
提问于 2011-05-30 11:26:05
回答 1查看 3.1K关注 0票数 2

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

代码语言:javascript
运行
AI代码解释
复制
- (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,我得到了什么,任何想法如何制作它

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-30 11:30:56

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

代码语言:javascript
运行
AI代码解释
复制
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6175670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档