开发者

A question about MKPinAnnotationView

Wish to specify the the color of a map pin other than the default red. From documentation, the MKP开发者_运维知识库inAnnotationView 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 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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜