版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
iOSSDK了解自定义了解@brief关联的@property(nonatomic,strong)id<MAAnnotation>@brief显示的@property(nonatomic,strong)UIImage@brief默认情况下,annotationview的中心位于annotation的坐标位置,可以设置@property(nonatomic)CGPointf 默认情况下, 弹出的气泡位于正中上方,以设置改变的偏移使@property(nonatomic)CGPoint@interfaceMAPinAnnotationView:导入标 文-(MAAnnotationView*)mapView:(MAMapView*)mapView{if([annotationisKindOfClass:[MAPointAnnotation{staticNSString*reuseIndetifier=MAAnnotationView*annotationView=(MAAnnotationView*)[mapViewif(annotationView=={annotationView=[[MAAnnotationViewalloc]initWithAnnotation:annotation}annotationView.image=[UIImage//设置中心点偏移,使得标注底部中间点成为 annotationView.centerOffset=CGPointMake(0,-18);returnannotationView;}return}56@interfaceCustomCalloutView:@property(nonatomic,strong)UIImage*image;@property(nonatomic,copy)NSString*title;@property(nonatomic,copy)NSString*subtitle;
-添加 自定义继承@interfaceCustomAnnotationView:@property(nonatomic,readonly)CustomCalloutView*calloutView;-(void)setSelected:(BOOL)selected7使用drawRect#pragmamark-draw-{[selfself.layer.shadowOpacity=1.0;self.layer.shadowOffset=CGSizeMake(0.0f,}-{CGContextSetLineWidth(context,CGContextSetFillColorWithColor(context,[UIColorcolorWithRed:0.3green:0.3blue:0.3[selfgetDra }- { CGFloatradius=6.0;midx=CGRectGetMidX(rrect),maxx=CGFloatminy=maxy=CGRectGetMaxY(rrect)-CGContextMoveToPoint(context,midx+kArrorHeight,maxy);CGContextAddLineToPoint(context,midx-kArrorHeight,CGContextAddArcToPoint(context,minx,maxy,minx,miny,radius);CGContextAddArcToPoint(context,minx,minx,maxx,miny,radius);CGContextAddArcToPoint(context,maxx,miny,maxx,maxx,radius);CGContextAddArcToPoint(context,maxx,maxy,midx,maxy,radius); 自定义修改calloutView@synthesizecalloutView={
修改calloutViewif(self.selected=={}if{
新建并添加if(self.calloutView=={self.calloutView.center=CGPointMake(CGRectGetWidth(self.bounds)/2.f+self.calloutOffset.x,}}
[self}{}
修改MAMapView的回调方法中的annotationView-(MAAnnotationView*)mapView:(MAMapView*)mapView{…CustomAnnotationView*annotationView=(CustomAnnotationView*)[mapViewdequeueReusableAnnotationViewWithIdentifier:reuseIndetifier];if(annotationView==nil){annotationView=[[CustomAnnotationViewalloc]initWithAnnotation:annotation}…}9自定义弹出气泡添加@interfaceCustomCalloutView@property(nonatomic,strong)UIImageView*portraitView;@property(nonatomic,strong)UILabel*subtitleLabel;@property(nonatomic,strong)UILabel*titleLabel;@implementation-{self=[superinitWithFrame:frame];if(self){self.backgroundColor=[UIColorclearColor];[selfinitSubViews];}return}-{#define #define #define #define #define //self.portraitView=[[UIImageViewalloc]initWithFrame:CGRectMake(kPortraitMargin,kPortraitMargin,kPortraitWidth,self.portraitView.backgroundColor=[UIColorblackColor];[selfaddSubview:self.portraitView];self.titleLabel=[[UILabelalloc]initWithFrame:CGRectMake(kPortraitMargin*2+kPortraitWidth,kPortraitMargin,kTitleWidth,kTitleHeight)];self.titleLabel.font=[UIFontboldSystemFontOfSize:14];self.titleLabel.textColor=[UIColorwhiteColor];self.titleLabel.text=@"titletitletitletitle";[selfaddSubview:self.titleLabel];self.subtitleLabel=[[UILabelalloc]initWithFrame:CGRectMake(kPortraitMargin*2+kPortraitWidth,kPortraitMargin*2+kTitleHeight,kTitleWidth,kTitleHeight)];self.subtitleLabel.font=[UIFontsystemFontOfSize:12];self.subtitleLabel.textColor=[UIColorlightGrayColor];[selfaddSubview:self.subtitleLabel];} 绑定数据和#pragmamark--(void)setTitle:(NSString{self.titleLabel.text=}-(void)setSubtitle:(NSString{self.subtitleLabel.text=}-(void)setImage:(UIImage{self.portraitView.image=}自定义选中时将数据传给@implementationCustomAnnotationView@synthesizecalloutView=_calloutView;-(void)setSelected:(BOOL)selected{…if{if(self.calloutView=={self.calloutView=[[CustomCalloutViewalloc]initWithFrame:CGRectMake(0,0,kCalloutWidth,kCalloutHeight)];self.calloutView.center=CGPointMake(CGRectGetWidth(self.bounds)/+-CGRectGetHeight(self.calloutView.bounds)/2.f+}self.calloutView.image=[UIImageimageNamed:@"building"];self.calloutViewself.calloutView.image=[UIImageimageNamed:@"building"];self.calloutView.title=self.annotation.title;self.calloutView.subtitle=self.annotation.subtitle;}…}自定义弹出气泡修复:选中气泡时认为选中点击气泡时,认为是选中annotation@implementationCustomAnnotationView@synthesizecalloutView=_calloutView;#pragmamark-…//重写此函数,用以实现点击calloutView判断为点击该
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五版汽车融资租赁合同示范文本(含电子签约)3篇
- 2025年度马戏团专业演出设备租赁合同3篇
- 二零二五年度地热资源打井开发与利用合同3篇
- 二零二五版模具行业财务顾问服务合同4篇
- 2025年度城市绿化工程苗木及配套设施采购年度合同3篇
- 二零二五年度民间借款合同(含金融消费者权益保护)
- 二零二五年度电子信息技术ICP证年审服务合同4篇
- 2025年保险科技的市场潜力
- 2025年度绿色农业贷款合同4篇
- 课题申报参考:美对华VC脱钩对中国企业关键核心技术突破的冲击及间接挂钩策略研究-共同所有权视角
- 暴发性心肌炎查房
- 口腔医学中的人工智能应用培训课件
- 工程质保金返还审批单
- 【可行性报告】2023年电动自行车项目可行性研究分析报告
- 五月天歌词全集
- 商品退换货申请表模板
- 实习单位鉴定表(模板)
- 机械制造技术-成都工业学院中国大学mooc课后章节答案期末考试题库2023年
- 数字媒体应用技术专业调研方案
- 2023年常州市新课结束考试九年级数学试卷(含答案)
- 正常分娩 分娩机制 助产学课件
评论
0/150
提交评论