IOS百度地图气泡内容自定义
来源:互联网 发布:淘宝键盘哪个牌子好 编辑:程序博客网 时间:2024/04/30 07:59
最简单,最直接的方法。。。
自定义一个 UIView
核心代码如下:
//改变标注图片和自定义气泡
-(BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation
{
BMKAnnotationView *annotationView=[[BMKAnnotationViewalloc]initWithAnnotation:annotationreuseIdentifier:@"myAnnotation"];
annotationView.image =[UIImageimageNamed:@"bike.gif"];
//自定义内容气泡
UIView *areaPaoView=[[UIViewalloc]initWithFrame:CGRectMake(0, 0, 200, 100)];
areaPaoView.layer.cornerRadius=8;
areaPaoView.layer.masksToBounds=YES;
areaPaoView.layer.contents =(id)[UIImageimageNamed:@"pao.png"].CGImage;//这张图片是做好的透明
//areaPaoView.backgroundColor=[UIColor whiteColor];
if ([annotation.titleisEqualToString:@"1"]) { //假设title的标题为1,那么就把添加上这个自定义气泡内容
UILabel * labelNo = [[UILabelalloc]initWithFrame:CGRectMake(10, 0, 200, 30)];
labelNo.text =[NSStringstringWithFormat:@"站点编号:%@"];
labelNo.textColor = [UIColorblackColor];
labelNo.backgroundColor = [UIColorclearColor];
[areaPaoViewaddSubview:labelNo];
UILabel * labelStationName = [[UILabelalloc]initWithFrame:CGRectMake(10, 20, 200, 30)];
labelStationName.text = [NSStringstringWithFormat:@"站点名称:昆山中学"];
labelStationName.textColor = [UIColorblackColor];
labelStationName.backgroundColor = [UIColorclearColor];
[areaPaoViewaddSubview:labelStationName];
UILabel * labelSumNum = [[UILabelalloc]initWithFrame:CGRectMake(10, 40, 200, 30)];
labelSumNum.text = [NSStringstringWithFormat:@"总桩数:30"];
labelSumNum.textColor = [UIColorblackColor];
labelSumNum.backgroundColor = [UIColorclearColor];
[areaPaoViewaddSubview:labelSumNum];
UILabel * labelBicycleNum = [[UILabelalloc]initWithFrame:CGRectMake(10, 60, 200, 30)];
labelBicycleNum.text = [NSStringstringWithFormat:@"可借车:20"];
labelBicycleNum.textColor = [UIColorblackColor];
labelBicycleNum.backgroundColor = [UIColorclearColor];
[areaPaoViewaddSubview:labelBicycleNum];
}
BMKActionPaopaoView *paopao=[[BMKActionPaopaoViewalloc]initWithCustomView:areaPaoView];
annotationView.paopaoView=paopao;
return annotationView;
}
- IOS百度地图气泡内容自定义
- iOS百度地图自定义大头针和气泡内的内容
- iOS 自定义百度地图标注气泡
- iOS-百度地图添加标注自定义气泡
- IOS百度地图自定义大头针和气泡
- IOS百度地图自定义大头针和气泡
- 百度地图自定义气泡
- 百度地图自定义气泡
- 百度地图IOS 自定义图标气泡viewForAnnotation不调用
- 百度地图自定义弹出气泡和大头针
- 百度地图(自定义标签、气泡)
- IOS 调用百度地图(SDK) 进行定位以及自定义位置弹出框(气泡)
- iOS百度地图自定义
- android版百度地图 自定义 点击当前位置弹出气泡
- 百度地图使用(二)自定义大头针和弹出气泡
- android版百度地图 自定义 点击当前位置弹出气泡
- android版百度地图 自定义 点击当前位置弹出气泡
- 百度地图使用-自定义大头针和弹出气泡
- 怎么实现MindMapper中的聚焦功能的灵活运用
- Java多线程-线程的同步与锁
- android开发需要知道的
- cf#VK Cup 2015 - Qualification Round 2-C - Name Quest-贪心
- CMake 学习笔记整理(6)
- IOS百度地图气泡内容自定义
- HYSBZ 1012(JSOI 2008) 最大数maxnumber(线段树点更新)
- iOS多线程编程技术之NSThread、Cocoa NSOperation、GCD
- char/byte数组转16进制字符串
- LPCTSTR类型
- C++实验2-标准体重
- 实例教学!12种透明背景的万能设计方法
- 算法搬运之堆排序
- list与arraylist 区别