1

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

是否可以加快 MKMapView 中注释的删除或一次删除所有注释?

4

1 回答 1

1

您需要在didAddAnnotationViews委托方法中实现自己的放置动画。您还应该设置animatesDropNO避免可能的双重动画。

- (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.

于 2011-07-01T15:12:00.557 回答