Elma Docs göre MKPinAnnotationView broşu renk, kırmızı mevcut yeşil ve mor olduğunu. Ayrıca diğer renkleri almak için herhangi bir yolu var mı? Ben docs hiçbir şey bulduk.
MKPinAnnotationView: üçten fazla renk mevcut var mı?
biraz daha ;)
alt metni http://lionel.gueganton.free.fr/pins/pinGray.png

alt metni http://lionel.gueganton.free.fr/pins/pinOrange.png

Ve orijinal olanlar:
alt metni http://lionel.gueganton.free.fr/pins/pinGreen.png

alt metni http://lionel.gueganton.free.fr/pins/pinPurple.png

alt metni http://lionel.gueganton.free.fr/pins/pinRed.png

Ve kod:
- (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;
}
Aşağıdaki görüntüler yarayabilecek:

ve kod bunları kullanmak 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];
}
// ...
Sen kullanabilirsiniz ZSPinAnnotationBelirtilen ile anında açıklama işaretçilerine oluşturmak için UIColor: https://github.com/nnhubbard/ZSPinAnnotation
Sevdiğim Yonel en Cevap Eğer özel bir MKAnnotationView oluştururken, el ofset atamak gerekecek kadar ama sadece kafaları. Yonel sağlanan görüntüler için: (bunlardan bir tane gerekmez eğer calloutButton atlayabiliriz)
#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;
}
IOS 9 ile pinTintColoreklendiğini MKPinAnnotationViewbir tedarik sağlayan, UIColorpim renk için.
Ve burada gölge ve içinde @ 2x boyutu ile pim PSD olduğunu.
http://dl.dropbox.com/u/5622711/ios-pin.psd
İstediğiniz renk için bu PSD kullanın :)
Bu PSD için kredi almak. Sadece onu yakaladı http://www.teehanlax.com/downloads/iphone-4-guid-psd-retina-display/ Onlar harika bir iş yapmış!
Eğer PIN açılan animasyon kullanıyorsanız yayınlanan çözümlerin hiçbiri% 100 çalışır. Görüldüğü pimi hala (sivri düşme ve dairesel kağıt dalgalanma olan) uçlarının her iki tür ancak ne yazık ki, orijinal pim başı renk bir belirti sağlar çünkü bombardıman çözeltisi çok temiz olması durumunda, pim zıpladığında o haritayı vurur. Bütün pim görüntüsünü değiştirme Yonel çözümü bile haritayı hit önce pim dairesel kağıt dalgalanması ile düşer demektir!
Ben bu şekilde çalıştı ve ok gibi görünüyor ...
UIImage * image = [UIImage imageNamed:@"blue_pin.png"];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:image]
autorelease];
[annotationView addSubview:imageView];
annotationView = nil;
yonel örnek olarak ... tam pimi görüntü kullanılarak
büyük olasılıkla daha sonra docs değil değilse, sen mkannotationview kullanabilir ve u olsa isterseniz ur kendi görüntü var













