Search code examples
ios7uibuttonmkannotationviewuiappearance

How to customize the calloutAccessoryView of a MKAnnotationView under iOS7?


Under iOS6 I did the following to set a custom image for the button of the right callout accessory view:

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setImage:[UIImage imageNamed:@"detaildisclosurebutton.png"] forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = rightButton;

That worked very well. Now I am updating the App to iOS7 and I just get a blue circle: Example

When I replace the image with a square image, it becomes a square. But it is blue too.

Seems to be the tintColor. I tried to set it to nil. I also tried to use buttonWithType:UIButtonTypeCustom as buttonType, but no success.

Has anyone a solution for it?


Solution

  • Button type UIButtonTypeDetailDisclosure tints the image by default. Use UIButtonTypeCustom instead.

    If you really need UIButtonTypeDetailDisclosure (and I can't think of a reason why you would given that you're setting a custom image, you can force your image to use "always original" rendering mode:

    [[UIImage imageNamed:@"detaildisclosurebutton.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]