您的位置:首页 > 其它

百度地图(自定义标签、气泡)

2015-12-18 15:30 190 查看
昨天写了一篇文章是关于百度地图定位的,刚好最近在写关于地图的模块,把工作中用到的记录下来,边学边用,也挺好的(不过太寂寞,不知道干什么)
今天就写一些自定义标签,弹出的气泡方法
挺简单的,直接上代码吧

if
([annotation
isKindOfClass:[BMKPointAnnotation
class]]) {

BMKPinAnnotationView
*newAnnotation = [[BMKPinAnnotationView
alloc]initWithAnnotation:annotation
reuseIdentifier:@"myAnnotation"];

newAnnotation.pinColor
=
BMKPinAnnotationColorPurple;

newAnnotation.animatesDrop
=
YES;

//设置弹出气泡图片

UIView
*popView = [[UIView
alloc]initWithFrame:CGRectMake(0,
0,
240,
280)];

popView.backgroundColor
= [UIColor
whiteColor];

//image

UIImageView
*image = [[UIImageView
alloc]initWithImage:[UIImage
imageNamed:@"moren"]];

image.frame
=
CGRectMake(0,
0,
240,
140);

[popView
addSubview:image];

//image1 text1

UIImageView
*image1 = [[UIImageView
alloc]initWithImage:[UIImage
imageNamed:@"yingpian2_ico_"]];

image1.frame
=
CGRectMake(10,
150,
20,
20);

[popView
addSubview:image1];

UILabel
*driverName = [[UILabel
alloc]initWithFrame:CGRectMake(40,
145,
100,
30)];

driverName.text
=
@"绝地逃亡";

driverName.font
= [UIFont
boldSystemFontOfSize:14];

driverName.textAlignment
=
NSTextAlignmentLeft;

[popView
addSubview:driverName];

//text2

UILabel
*name2 = [[UILabel
alloc]initWithFrame:CGRectMake(10,
185,
100,
20)];

name2.text
=
@"成龙";

name2.font
= [UIFont
boldSystemFontOfSize:13];

name2.textAlignment
=
NSTextAlignmentLeft;

[popView
addSubview:name2];

//text3

UILabel
*name3 = [[UILabel
alloc]initWithFrame:CGRectMake(10,
210,
100,
20)];

name3.text
=
@"中国
云南";

name3.font
= [UIFont
systemFontOfSize:13];

name3.textAlignment
=
NSTextAlignmentLeft;

[popView
addSubview:name3];

//button

UIButton
*btn = [UIButton
buttonWithType:UIButtonTypeCustom];

btn.frame
=
CGRectMake(0,
250,
240,
30);

[btn
setTitle:@"进入"
forState:UIControlStateNormal];

btn.backgroundColor
= [UIColor
colorWithRed:236/255.0
green:85/255.0
blue:77/255.0
alpha:1];

// [btn setBackgroundImage:[UIImage imageNamed:@"wo_beijing"] forState:UIControlStateNormal];

[popView
addSubview:btn];

BMKActionPaopaoView
*pView = [[BMKActionPaopaoView
alloc]initWithCustomView:popView];

pView.frame
=
CGRectMake(0,
0,
240,
280);

((BMKPinAnnotationView*)newAnnotation).paopaoView
=
nil;

((BMKPinAnnotationView*)newAnnotation).paopaoView
= pView;

return
newAnnotation;

}

最后效果图,点击大头针出现



我创建了一个交流群,大家可以加一下一起交流
”进修Android~iOS+“
群:237311061 大神在里面,而且群里面会分享有一些iOS课件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: