ios 地图大头针自定义显示图片 MKAnnotationView

来源:互联网 发布:知微数据招聘 编辑:程序博客网 时间:2024/05/21 10:13

通过判断 title 来设置自定义图片,在代理方法中:

 -(MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id )annotation { MKAnnotationView *newAnnotation=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"]; if ([[annotation title] isEqualToString:@"当前位置"]) { newAnnotation.image = [UIImage imageNamed:@"person_location"]; } else{ newAnnotation.image = [UIImage imageNamed:@"login_logo_small"]; } newAnnotation.canShowCallout=YES; return newAnnotation; }

0 0
原创粉丝点击