nobu86
nobu86

Reputation: 55

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

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

Is it possible speed up the drop of annotation in MKMapView or drop all of them at once?

Upvotes: 1

Views: 1214

Answers (1)

user467105
user467105

Reputation:

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.

Upvotes: 1

Related Questions