1. 程式人生 > >ios 地圖大頭針自定義顯示圖…

ios 地圖大頭針自定義顯示圖…

通過判斷 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; }