MKPinAnnotationView: वहाँ तीन से अधिक रंगों में उपलब्ध हैं?

वोट
39

एप्पल डॉक्स के अनुसार, MKPinAnnotationView के पिन रंग, लाल रंग में उपलब्ध हरा और बैंगनी है। वहाँ किसी भी तरह से भी अन्य रंग प्राप्त करने के लिए है? मैं डॉक्स में कुछ भी नहीं पाया है।

26/07/2009 को 22:32
का स्रोत उपयोगकर्ता
अन्य भाषाओं में...                            


9 जवाब

वोट
81

कुछ और ;)

वैकल्पिक पाठ 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;
}
14/01/2010 को 19:24
का स्रोत उपयोगकर्ता

वोट
40

आप नीचे दिए गए छवियों उपयोगी लग सकते:

वैकल्पिक शब्द वैकल्पिक शब्द वैकल्पिक शब्द वैकल्पिक शब्द

और कोड में उन्हें इस्तेमाल करने 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];
    }
    // ...
26/12/2009 को 15:09
का स्रोत उपयोगकर्ता

वोट
11

आप इस्तेमाल कर सकते हैं ZSPinAnnotationके साथ एक निर्दिष्ट मक्खी पर एनोटेशन पिन बनाने के लिए UIColor: https://github.com/nnhubbard/ZSPinAnnotation

19/01/2012 को 19:57
का स्रोत उपयोगकर्ता

वोट
8

मुझे पसंद है 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;
}
31/05/2010 को 18:59
का स्रोत उपयोगकर्ता

वोट
4

आईओएस 9 के साथ, pinTintColorकरने के लिए जोड़ दिया गया है MKPinAnnotationViewआप एक आपूर्ति करने के लिए अनुमति देता है, UIColorपिन रंग के लिए।

14/10/2015 को 13:29
का स्रोत उपयोगकर्ता

वोट
4

और यहाँ छाया और उसके में @ 2x आकार के साथ पिन के लिए PSD है।

http://dl.dropbox.com/u/5622711/ios-pin.psd

किसी भी रंग आप चाहते हैं के लिए इस PSD का उपयोग करें :)

मैं इस PSD के लिए कोई क्रेडिट ले लो। मैं सिर्फ यह पकड़ा से http://www.teehanlax.com/downloads/iphone-4-guid-psd-retina-display/ वे एक अद्भुत काम किया है!

23/12/2011 को 23:09
का स्रोत उपयोगकर्ता

वोट
3

पोस्ट से कोई भी समाधान 100% काम आप पिन ड्रॉप एनीमेशन प्रयोग कर रहे हैं। गोलाबारी के समाधान बहुत साफ है, क्योंकि यह देखा जा सकता है पिन अभी भी समाप्त हो जाती है दोनों प्रकार के (तेज बिंदु जब गिरने और परिपत्र कागज लहर के साथ) लेकिन दुर्भाग्य से मूल पिन सिर रंग की एक झलक की अनुमति देता है जब के रूप में पिन बाउंस यह नक्शा पूरी करता है। पूरे पिन छवि बदलने की yonel के समाधान का मतलब है पहले यह भी नक्शा मारा है पिन परिपत्र कागज लहर के साथ हो जाता!

30/11/2010 को 21:39
का स्रोत उपयोगकर्ता

वोट
2

मैं इस तरह की कोशिश की और यह ठीक हो रहा है ...

UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
        UIImageView *imageView = [[[UIImageView alloc] initWithImage:image]
                                 autorelease];
        [annotationView addSubview:imageView];
        annotationView = nil;

पूरा पिन छवि का उपयोग कर ... yonel उदाहरण के रूप में

18/11/2010 को 18:00
का स्रोत उपयोगकर्ता

वोट
1

यदि यह संभवत: नहीं किए गए दस्तावेज़ों में नहीं है तो, आप mkannotationview का उपयोग करें और यदि u हालांकि इच्छा उर स्वयं की छवि हो सकता है

26/07/2009 को 23:19
का स्रोत उपयोगकर्ता

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more