ฉันได้ค้นหาโซลูชันที่คล้ายกันเกี่ยวกับวิธีออกแบบ MKAnnotationView แบบกำหนดเองเช่นนี้
ฉันได้จัดคลาสย่อย MKAnnotation และฉันสามารถเพิ่มรูปภาพชื่อ F.png ได้ F.png เป็นรูปภาพเฟรมตามที่แสดงในรูปภาพ สิ่งที่ฉันต้องการคือการเพิ่มภาพภายใน (สีฟ้าในภาพที่ฉันวาด)
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if(annotationView)
return annotationView;
else
{
MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"F.png"]];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self action:@selector(writeSomething:) forControlEvents:UIControlEventTouchUpInside];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = rightButton;
annotationView.canShowCallout = YES;
annotationView.draggable = NO;
return annotationView;
}
return nil;
}