質問

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