In my project i need to change the Pin color based on different RGB values in MKMapView, When applied RGB values it is showing Red Pin in default. Is there any other way to apply RGB values or do we need to change the image only for that. Please let me know.

MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MyPin"];


    **annView.pinColor = [UIColor colorWithRed:132.0/255 green:191.0/255 blue:240.0/255 alpha:1.0];**

It is not working. always showing Red as default.

有帮助吗?

解决方案

You can't use the customized color in mkannotationview. You can only use the Red, Green, Purple color by using this

        annotationView.pinColor = MKPinAnnotationColorRed;
        annotationView.pinColor = MKPinAnnotationColorPurple;
        annotationView.pinColor = MKPinAnnotationColorGreen;

Otherwise use image like this

        annotationView.image = [UIImage imageNamed:@"image.png"];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top