Skip to content

Instantly share code, notes, and snippets.

@jstart
Created April 16, 2012 15:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstart/2399387 to your computer and use it in GitHub Desktop.
Save jstart/2399387 to your computer and use it in GitHub Desktop.
MKAnnotationView Animation example
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
if ([views count] > 1 && self.animatePins) { //Use a boolean to make sure animation does not get interrupted
MKAnnotationView *animateAV;
int i = 0;
self.animatePins = NO;
NSLog(@"did add annotationview, count:%d", [views count]);
for (animateAV in views) {
CGRect endFrame = animateAV.frame;
i= i + 120;
animateAV.frame = CGRectMake(animateAV.frame.origin.x, animateAV.frame.origin.y - (230.0+i), animateAV.frame.size.width, animateAV.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[animateAV setFrame:endFrame];
[UIView commitAnimations];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment