开发者

MapView Custom annotation drop

开发者 https://www.devze.com 2023-02-06 17:22 出处:网络
I am trying to create a custom annotation for the map. The problem I have is , I can\'t make the annotation drop one after the other. All pins drop down at the same time. Here is the delegate code for

I am trying to create a custom annotation for the map. The problem I have is , I can't make the annotation drop one after the other. All pins drop down at the same time. Here is the delegate code for didAddAnnotations. Can you help me to rewrite the code so tha开发者_如何学运维t I can make the custom annotations drop one after the other..just like it happens when we use default annotations. Thanks in advance....!!!!

- (void) mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {

    CGRect visibleRect = [mapView annotationVisibleRect]; 

    for (MKAnnotationView *view in views) {
        CGRect endFrame = view.frame;

        CGRect startFrame = endFrame;
        startFrame.origin.y = visibleRect.origin.y - startFrame.size.height;
        view.frame = startFrame;

        [UIView beginAnimations:@"drop" context:NULL]; 
        [UIView setAnimationDuration:1];

        view.frame = endFrame;

        [UIView commitAnimations];
    } // end of for 
} // end of delegate


You could add a delay that becomes a little longer in each iteration of your loop, like this:

double delay = 0.0;
for (MKAnnotationView *view in views) {
    CGRect endFrame = view.frame;
    CGRect startFrame = endFrame;
    startFrame.origin.y = visibleRect.origin.y - startFrame.size.height;
    view.frame = startFrame;
    [UIView beginAnimations:@"drop" context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelay:delay];
    view.frame = endFrame;
    [UIView commitAnimations];
    delay += 0.1;
}
0

精彩评论

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