开发者

Is it possible speed up the drop of annotation in MKMapView?

开发者 https://www.devze.com 2023-03-16 14:12 出处:网络
I have something like 30 annotations in my map and I want speed up the dropping animation. Is it possible spe开发者_StackOverflowed up the drop of annotation in MKMapView or drop all of them at once?

I have something like 30 annotations in my map and I want speed up the dropping animation.

Is it possible spe开发者_StackOverflowed up the drop of annotation in MKMapView or drop all of them at once?


You'll need to implement your own drop animation in the didAddAnnotationViews delegate method. You should also set animatesDrop to NO to avoid a possible double animation.

- (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;
    }
}

This drops the annotations at a rate you specify.

To drop them all at once, hard-code the delay parameter to 0.0 instead of the incrementing delayInterval.

0

精彩评论

暂无评论...
验证码 换一张
取 消