How do I animate MKAnnotationView drop?

前端 未结 7 1190
情书的邮戳
情书的邮戳 2020-11-29 01:48

I have a custom MKAnnotationView where I set my image myself in viewForAnnotation. How do I animate it\'s drop like I can with MKPinAnnotationView?

My code is

7条回答
  •  醉话见心
    2020-11-29 02:35

    Implement the didAddAnnotationViews delegate method and do the animation yourself:

    - (void)mapView:(MKMapView *)mapView 
              didAddAnnotationViews:(NSArray *)annotationViews
    {
        for (MKAnnotationView *annView in annotationViews)
        {
            CGRect endFrame = annView.frame;
            annView.frame = CGRectOffset(endFrame, 0, -500);
            [UIView animateWithDuration:0.5 
                    animations:^{ annView.frame = endFrame; }];
        }
    }
    

提交回复
热议问题