Evet, bu mümkün.
iOS MapKit uygulamasında, viewForAnnotation
temsilci yöntemini uygulamanız ve MKAnnotationView
ürününe UILabel
ekleyerek geri göndermeniz gerekir. Örneğin
:
-(MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString *reuseId = @"reuseid";
MKAnnotationView *av = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseId];
if (av == nil)
{
av = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId] autorelease];
UILabel *lbl = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 30)] autorelease];
lbl.backgroundColor = [UIColor blackColor];
lbl.textColor = [UIColor whiteColor];
lbl.alpha = 0.5;
lbl.tag = 42;
[av addSubview:lbl];
//Following lets the callout still work if you tap on the label...
av.canShowCallout = YES;
av.frame = lbl.frame;
}
else
{
av.annotation = annotation;
}
UILabel *lbl = (UILabel *)[av viewWithTag:42];
lbl.text = annotation.title;
return av;
}
haritası görünümün
delegate
mülkiyet aksi takdirde bu temsilci yöntemi denir almazsınız belirlendiğinden emin olun ve bunun yerine varsayılan kırmızı işaretçilerine alacak.
Merhaba, biraz daha ayrıntılı deneyin. Denediğin şeyin bazı kodları olabilir. –