Wednesday, August 8, 2012

How to Create Custom Map Annotation Button



Custom accessory button for MKPinAnnotationView right side, create inside MKMapViewDelegate protocol mapView:viewForAnnotation method:
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
[button setImage:[UIImage imageNamed:@"myButton.png"] forState:UIControlStateNormal]; 
view.rightCalloutAccessoryView = button;
Usually sample codes use UIButtonTypeDetailDisclosure as right button, but you can't use that unless you really show additional details. For anything else, you must use a custom button.

No comments:

Post a Comment