生活随笔
收集整理的這篇文章主要介紹了
iOS中设置百度地图自定义标注图片,自定义泡泡
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#pragma?mark?-?BMKMapViewDelegate?? ?? ?? ?? -?(BMKAnnotationView?*)mapView:(BMKMapView?*)mapView?viewForAnnotation:(id?<BMKAnnotation>)annotation?? ?? {?? ?? ?????? ?? ????NSString?*AnnotationViewID?=?@"ClusterMark";?? ?? ????ClusterAnnotation?*cluster?=?(ClusterAnnotation*)annotation;?? ?? ????ClusterAnnotationView?*annotationView?=?[[ClusterAnnotationView?alloc]?initWithAnnotation:annotation?reuseIdentifier:AnnotationViewID];?? ?? ????annotationView.size?=?cluster.size;?? ?? ????annotationView.canShowCallout?=?NO;?? ?? ????annotationView.draggable?=?NO;?? ?? ????annotationView.annotation?=?cluster;?? ?? ?? ?? ????annotationView.centerOffset=CGPointMake(0,0);?? ?? ?????? ?? ????UIView?*viewForImage=[[UIView?alloc]initWithFrame:CGRectMake(0,?0,?110,?110)];?? ?? ????UIImageView?*imageview=[[UIImageView?alloc]initWithFrame:CGRectMake(0,?0,?110,?110)];?? ?? ????[imageview?setImage:[UIImage?imageWithData:[NSData?dataWithContentsOfURL:[NSURL?URLWithString:annotation.subtitle]]]];?? ?? ????imageview.layer.masksToBounds=YES;?? ?? ????imageview.layer.cornerRadius?=?10;?? ?? ????[viewForImage?addSubview:imageview];?? ?? ????annotationView.image=[self?getImageFromView:viewForImage];?? ?? ????return?annotationView;?? ?? }?? ?? ?? -(UIImage?*)getImageFromView:(UIView?*)view{?? ?? ????UIGraphicsBeginImageContext(view.bounds.size);?? ?? ????[view.layer?renderInContext:UIGraphicsGetCurrentContext()];?? ?? ????UIImage?*image?=?UIGraphicsGetImageFromCurrentImageContext();?? ?? ????UIGraphicsEndImageContext();?? ?? ????return?image;?? ?? }?? ?? ?? ?? annotationView.leftCalloutAccessoryView?=?[[UIImageView?alloc]?initWithImage:[UIImage?imageNamed:@"icon_location.png"]];?? ?? annotationView.rightCalloutAccessoryView?=selectButton;?? ?? [annotationView?setSelected:YES?animated:YES]; ?
總結(jié)
以上是生活随笔為你收集整理的iOS中设置百度地图自定义标注图片,自定义泡泡的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。