हां, यह संभव है।
आईओएस मैपकिट में, आपको viewForAnnotation
प्रतिनिधि विधि को लागू करने की आवश्यकता होगी और के साथ MKAnnotationView
को वापस करने की आवश्यकता होगी।
उदाहरण के लिए:
-(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;
}
सुनिश्चित करें मानचित्र दृश्य के delegate
संपत्ति अन्यथा इस प्रतिनिधि विधि कहा जाता है नहीं किया जाएगा सेट किया गया है और आप डिफ़ॉल्ट लाल पिन के बजाय मिल जाएगा।
हैलो, थोड़ा और विस्तार करने का प्रयास करें। आपने जो कुछ किया है उसका कुछ कोड हो सकता है। –