एप्पल डॉक्स के अनुसार, MKPinAnnotationView के पिन रंग, लाल रंग में उपलब्ध हरा और बैंगनी है। वहाँ किसी भी तरह से भी अन्य रंग प्राप्त करने के लिए है? मैं डॉक्स में कुछ भी नहीं पाया है।
MKPinAnnotationView: वहाँ तीन से अधिक रंगों में उपलब्ध हैं?
कुछ और ;)
वैकल्पिक पाठ http://lionel.gueganton.free.fr/pins/pinGray.png

वैकल्पिक पाठ http://lionel.gueganton.free.fr/pins/pinOrange.png

और मूल लोगों को:
वैकल्पिक पाठ http://lionel.gueganton.free.fr/pins/pinGreen.png

वैकल्पिक पाठ http://lionel.gueganton.free.fr/pins/pinPurple.png

वैकल्पिक पाठ http://lionel.gueganton.free.fr/pins/pinRed.png

और कोड:
- (MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView* anView =[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"test"];
anView.pinColor=MKPinAnnotationColorPurple;
UIImage* image = nil;
// 2.0 is for retina. Use 3.0 for iPhone6+, 1.0 for "classic" res.
UIGraphicsBeginImageContextWithOptions(anView.frame.size, NO, 2.0);
[anView.layer renderInContext: UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData* imgData = UIImagePNGRepresentation(image);
NSString* targetPath = [NSString stringWithFormat:@"%@/%@", [self writablePath], @"thisismypin.png" ];
[imgData writeToFile:targetPath atomically:YES];
return anView;
}
-(NSString*) writablePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return documentsDirectory;
}
आप नीचे दिए गए छवियों उपयोगी लग सकते:

और कोड में उन्हें इस्तेमाल करने viewForAnnotation :
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
// ... get the annotation delegate and allocate the MKAnnotationView (annView)
if ([annotationDelegate.type localizedCaseInsensitiveCompare:@"NeedsBluePin"] == NSOrderedSame)
{
UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image] autorelease];
[annView addSubview:imageView];
}
// ...
आप इस्तेमाल कर सकते हैं ZSPinAnnotationके साथ एक निर्दिष्ट मक्खी पर एनोटेशन पिन बनाने के लिए UIColor: https://github.com/nnhubbard/ZSPinAnnotation
मुझे पसंद है Yonel के जवाब लेकिन सिर्फ एक सिर ऊपर, जब आप एक कस्टम MKAnnotationView बनाते हैं, तो आप मैन्युअल रूप से आवंटित करने के लिए ऑफसेट होगा। छवियों Yonel प्रदान किया था: (आप calloutButton सामान छोड़ सकते हैं अगर आप उन में से एक की जरूरत नहीं है)
#pragma mark MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if(![annotation isKindOfClass:[MyAnnotation class]]) // Don't mess user location
return nil;
MKAnnotationView *annotationView = [aMapView dequeueReusableAnnotationViewWithIdentifier:@"spot"];
if(!annotationView)
{
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"spot"];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[(UIButton *)annotationView.rightCalloutAccessoryView addTarget:self action:@selector(openSpot:) forControlEvents:UIControlEventTouchUpInside];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.centerOffset = CGPointMake(7,-15);
annotationView.calloutOffset = CGPointMake(-8,0);
}
// Setup annotation view
annotationView.image = [UIImage imageNamed:@"pinYellow.png"]; // Or whatever
return annotationView;
}
आईओएस 9 के साथ, pinTintColorकरने के लिए जोड़ दिया गया है MKPinAnnotationViewआप एक आपूर्ति करने के लिए अनुमति देता है, UIColorपिन रंग के लिए।
और यहाँ छाया और उसके में @ 2x आकार के साथ पिन के लिए PSD है।
http://dl.dropbox.com/u/5622711/ios-pin.psd
किसी भी रंग आप चाहते हैं के लिए इस PSD का उपयोग करें :)
मैं इस PSD के लिए कोई क्रेडिट ले लो। मैं सिर्फ यह पकड़ा से http://www.teehanlax.com/downloads/iphone-4-guid-psd-retina-display/ वे एक अद्भुत काम किया है!
पोस्ट से कोई भी समाधान 100% काम आप पिन ड्रॉप एनीमेशन प्रयोग कर रहे हैं। गोलाबारी के समाधान बहुत साफ है, क्योंकि यह देखा जा सकता है पिन अभी भी समाप्त हो जाती है दोनों प्रकार के (तेज बिंदु जब गिरने और परिपत्र कागज लहर के साथ) लेकिन दुर्भाग्य से मूल पिन सिर रंग की एक झलक की अनुमति देता है जब के रूप में पिन बाउंस यह नक्शा पूरी करता है। पूरे पिन छवि बदलने की yonel के समाधान का मतलब है पहले यह भी नक्शा मारा है पिन परिपत्र कागज लहर के साथ हो जाता!
मैं इस तरह की कोशिश की और यह ठीक हो रहा है ...
UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image]
autorelease];
[annotationView addSubview:imageView];
annotationView = nil;
पूरा पिन छवि का उपयोग कर ... yonel उदाहरण के रूप में
यदि यह संभवत: नहीं किए गए दस्तावेज़ों में नहीं है तो, आप mkannotationview का उपयोग करें और यदि u हालांकि इच्छा उर स्वयं की छवि हो सकता है













