Пользовательский MKAnnotationView с рамкой, значком и изображением
Я искал подобное решение о том, как спроектировать пользовательский MKAnnotationView, такой как этот.
Я подклассифицировал MKAnnotation и смог добавить изображение с именем F.png F.png - это изображение кадра, как показано на рисунке. что я хочу, это добавить внутреннее изображение. (синий цвет на рисунке я рисую)
<code>- (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; } </code>