Kuba Kuba - 1 year ago 221
iOS Question

set TintColor to MKAnnotationView image

I'm writing an application for

iOS 7.0+
and I wanted to use new feature witch is:
. I have a map annotation with this code:

-(MKAnnotationView*)annotationView {
MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:self reuseIdentifier:@"AnnotationIdentifier"];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = [[UIImage imageNamed:@"star"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.tintColor = [UIColor redColor];
return annotationView;

I was expected that my pins will be red, but stays black, only the callout (i) icon turns red.

enter image description here

I was trying to set
in my
but this not working either. How to turns this pins red?

Answer Source

It does not appear that you are able to accomplish this at all using tintColor. MKAnnotationView does not use the tint color for image rendering like a UIImageView does. You'll need to either write some sort of method to draw a correctly colored image yourself, or provide an image with the color you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download