Add image behind MKPinAnnotationView

后端 未结 3 949
南笙
南笙 2021-02-04 22:05

I\'m trying to add an image behind a MKPinAnnotationView. Seems like it should be rather easy to just do this in here:

- (void)mapView:(MKMapView *)mapView didAd         


        
3条回答
  •  萌比男神i
    2021-02-04 22:25

    Create a new composite annotationview that first adds your image and then the actual MKAnnotationView:

    @implementation MyCustomAnnotationView
    
    - (void) viewDidLoad 
    {   
        // First add the image to our subviews
        UIImageView *view = [[UIImageView alloc] initWithImage: myImageProperty];
        [self.view addSubview: view];
        [view release];
    
        // Then add the MKAnnotationView on top of it
        MKAnnotationView *annotation = [[MKAnnotationView alloc] init]; 
        [self.view addSubview: annotation]; 
        [annotation release];
    }                        
    
    @end  
    

提交回复
热议问题