




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
iOSSDK了解自定義了解@brief關(guān)聯(lián)的@property(nonatomic,strong)id<MAAnnotation>@brief顯示的@property(nonatomic,strong)UIImage@brief默認情況下,annotationview的中心位于annotation的坐標位置,可以設(shè)置@property(nonatomic)CGPointf 默認情況下, 彈出的氣泡位于正中上方,以設(shè)置改變的偏移使@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//設(shè)置中心點偏移,使得標注底部中間點成為 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的回調(diào)方法中的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];} 綁定數(shù)據(jù)和#pragmamark--(void)setTitle:(NSString{self.titleLabel.text=}-(void)setSubtitle:(NSString{self.subtitleLabel.text=}-(void)setImage:(UIImage{self.portraitView.image=}自定義選中時將數(shù)據(jù)傳給@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-…//重寫此函數(shù),用以實現(xiàn)點擊calloutView判斷為點擊該
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2022下半年教師資格證考試《小學英語專業(yè)面試》真題及答案解析
- 駕駛員派遣合同范本
- 創(chuàng)新創(chuàng)業(yè)答辯會議
- 2025年西班牙語DELE考試真題卷:DELE考試備考資料匯編試題
- 2025年中學教師資格考試《綜合素質(zhì)》教育熱點案例分析題庫沖刺試卷(含答案)
- 2025年小學英語畢業(yè)考試模擬試卷:英語短劇表演腳本編寫與聽力訓練試題
- 2025年茶藝師職業(yè)技能競賽茶藝師茶葉產(chǎn)品組合策略與定價試題
- 2025年帆船教練專業(yè)能力考核試卷:帆船運動教學案例分析與實踐
- 2025年職業(yè)指導師專業(yè)能力測試卷:職業(yè)指導師咨詢倫理與實踐試題
- 村集體改革產(chǎn)權(quán)制度2025年
- 華北理工牙體牙髓學實驗課件02窩洞的結(jié)構(gòu)分類及石膏牙備洞
- 《色彩基礎(chǔ)知識》PPT課件(完整版)
- 專利管理制度管理辦法
- 拖拉機和聯(lián)合收割機駕駛?cè)松眢w條件證明
- 機電控制與可編程序控制器課程設(shè)計
- 基于ADAMS的懸置剛度仿真指南
- 彎矩二次分配法EXCEL計算
- 分數(shù)小數(shù)混合運算練習80題
- 童話故事《老鼠搬雞蛋》.ppt
- 偏差管理和CAPA_王麗麗
- 北京大學數(shù)學物理方法經(jīng)典課件第五章——傅里葉變換
評論
0/150
提交評論