百度地图(自定义标签、气泡)
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课件
今天就写一些自定义标签,弹出的气泡方法
挺简单的,直接上代码吧
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课件
相关文章推荐
- android手机连接android wear (手表模拟器)的连接
- DEDECMS{dede:channelartlist}autoindex无效用itemindex代替及他
- Linux应用帮助你来征服数学学习
- XSuperMES
- 自定义view的绘制
- yum来管理安装Apache PHP Mysql的基本安装
- 顺序结构
- 使用python操作solr
- TCP/IP、Http、Socket的区别
- 多线程技术,一般用来写单例
- UIApplication
- Android 万能适配器
- 黑马程序员 - OC语言 - 重写构造方法
- 机器手臂(3):机械手臂底座
- JAVA的StringBuffer类
- 用十条命令在一分钟内检查Linux服务器性能
- jsp中的basePath和path
- python多线程
- 也谈文件的多线程下载
- Android 使用Fragment 替换 TabActivity