是否有可能加快MKMapView中注释的下降?

时间:2011-07-01 13:38:50

标签: ios mkmapview mkannotation mkannotationview

我的地图中有30个注释,我想加快下降动画的速度。

是否有可能加快MKMapView中注释的删除或立即删除所有注释?

1 个答案:

答案 0 :(得分:1)

您需要在didAddAnnotationViews委托方法中实现自己的投放动画。您还应将animatesDrop设置为NO以避免可能的双重动画。

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)annotationViews
{
    NSTimeInterval delayInterval = 0;

    for (MKAnnotationView *annView in annotationViews)
    {
        CGRect endFrame = annView.frame;

        annView.frame = CGRectOffset(endFrame, 0, -500);

        [UIView animateWithDuration:0.125 
                              delay:delayInterval
                            options:UIViewAnimationOptionAllowUserInteraction 
                         animations:^{ annView.frame = endFrame; } 
                         completion:NULL];

        delayInterval += 0.0625;
    }
}

这会以您指定的速率删除注释。

要一次删除所有内容,请将delay参数硬编码为0.0,而不是递增delayInterval