自定义注释标注视图或自定义视图?

Custom Annotation Callout View or Custom View ?

我目前正在构建一个 "Uber-like" 应用程序,不在同一业务但设计相同,我想知道如果我想代表他们应该怎么做 "Set pickup location" View/Button。

我已经看到这个 post : 这是关于自定义注释标注视图

在旧版本中,它看起来像一个自定义标注视图,但现在有点不同,如果我想得到相同的结果,我不知道从哪里开始:

感谢您的帮助!

要在左附件和右附件上设置不同的图像,请使用此代码。

 // set different pins colors
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKAnnotationView *annotationView = nil;
if( [annotation isKindOfClass:[YOURANNOTATION class] ] )
{
    static NSString * AnnotationID = @"YOURANNOTATION";
    annotationView = [self.mapView  dequeueReusableAnnotationViewWithIdentifier:AnnotationID];
    if( annotationView == nil )
    {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
                                                       reuseIdentifier:AnnotationID] ;

    }
    UIImage * flagImage = nil;

            flagImage = [UIImage imageNamed:@"marker-map@1x.png"];
            [annotationView setImage:flagImage];
            annotationView.canShowCallout = YES;

            //   add an image to the callout window
            UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"marker-map@1x.png"]];
            annotationView.leftCalloutAccessoryView = leftIconView;


    //adding right button accessory
    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    annotationView.rightCalloutAccessoryView = infoButton;

    //image size and adding image on left accessory
    CGRect resizeRect;
    resizeRect.size = flagImage.size;
    resizeRect.origin = (CGPoint){0.0f, 0.0f};
    UIGraphicsBeginImageContext(resizeRect.size);
    [flagImage drawInRect:resizeRect];
    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();    
    annotationView.image = resizedImage;

}
return annotationView;

}

然后调用选定的注释

  - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
 {


YOURANNOTATION *annotation=(YOURANNOTATION*)view.annotation;

 //do something with your annotation

 }