The standard callout, a black bubble, is nice, but can this be customized? For instance I would like to make a white bubble version.
Asked
Active
Viewed 8,429 times
6
-
Possible duplicate of [Customizing the MKAnnotation Callout bubble](http://stackoverflow.com/questions/4094325/customizing-the-mkannotation-callout-bubble) – Sandy Chapman Dec 07 '15 at 13:28
1 Answers
7
There is a great answer to this problem here: Customizing the MKAnnotation Callout bubble
Where this answer is given by @MathieuF:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];
// Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = CGRectMake(0, 0, 23, 23);
annotationView.rightCalloutAccessoryView = button;
// Image and two labels
UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,0,23,23)];
[leftCAV addSubview : yourImageView];
[leftCAV addSubview : yourFirstLabel];
[leftCAV addSubview : yourSecondLabel];
annotationView.leftCalloutAccessoryView = leftCAV;
annotationView.canShowCallout = YES;
return pin;
}
-
3That's great, but it doesn't deal with the triangle that comes down from the bubble, or variable width bubbles (to contain variable amounts of text) – cannyboy Aug 05 '11 at 07:25
-
@cannyboy same problem here. Can you please let me know how did you solved it?? – Tapas Pal Sep 08 '15 at 13:31
-
i need two Buttons one on leftView & rightView ? how to add Custom Button with action to the Left View and rightView ? – Sanju Feb 21 '16 at 15:11