问题描述:

Wish to specify the the color of a map pin other than the default red. From documentation, the MKPinAnnotationView class has a pinColor property where we can set the color. My question is : what is the proper way to associate this pinColor property with an annotation object?

Wish that somebody knowledgable on this could help ...

网友答案:

I hope I understand you question correctly. I guess that would be part of your logic and that there's no one "correct" answer. In one app I might have a plist containing definitions of all the objects in my app and their properties. In another more simple app I might just specify the color based upon an index when it's created for example.

If you just want to know how to set a property then follow Shrey's advice above

网友答案:

i think only three colors are defined for pinColor property.

enum {
   MKPinAnnotationColorRed = 0,
   MKPinAnnotationColorGreen,
   MKPinAnnotationColorPurple
};
typedef NSUInteger MKPinAnnotationColor;

Here's the method to define it.

MKPinAnnotationView* customPinView = [[[MKPinAnnotationView alloc]
                                             initWithAnnotation:annotation reuseIdentifier:MyAnnotationIdentifier] autorelease];
            customPinView.pinColor = MKPinAnnotationColorPurple;
相关阅读:
Top