views:

579

answers:

1

I, do you know that MKPinAnnotationView has a method "animatesDrop" to animate a pin annotation from the top to point on the map with a shadow?!..OK...is possible do this with a custom image??

thanks..:)

+1  A: 

You can always do your custom animation in MKMapViewDelegate method.

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

Probably something like that (you won't get the fancy shadow animation, if you want it you need to do it yourself) :

- (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];
    }
}
gcamp
@gcamp: i've try also in this way but not work (the image not change):MKPinAnnotationView *annView=[mapView dequeueReusableAnnotationViewWithIdentifier:ident];annView=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:ident]autorelease];annView.image =[UIImage imageNamed:@"annotImg.png"];annView.animatesDrop=TRUE;
Mat
Changed my answer!
gcamp
thanks much!..this is very useful for me!
Mat
Nice work! Found this link as well, which is very similar … so now all we need is the squish effect at the end. Probably another animation that momentarily squishes the image height at the tail end.http://stackoverflow.com/questions/1857160/how-can-i-create-a-custom-pin-drop-animation-using-mkannotationview/2087253#2087253
Joe D'Andrea