//自定义大头针不能使用系统的MKPinAnnotationView来添加从天儿降的效果,只能自己添加动画
#pragma mark MKMapViewDelegate
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView;
for (annotationView in views)
{
if (![annotationView isKindOfClass:[MKPinAnnotationView class]])
{
CGRect endFrame = annotationView.frame;
annotationView.frame = CGRectMake(endFrame.origin.x, endFrame.origin.y - 500.0, endFrame.size.width, endFrame.size.height);
[UIView beginAnimations:@"drop" context:NULL];
[UIView setAnimationDuration:0.45];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[annotationView setFrame:endFrame];
[UIView commitAnimations];
}
}
}
//使用系统的大头针添加动画
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation
{
MKPinAnnotationView *pinView = nil;
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
[mapView.userLocation setTitle:@"欧陆经典"];
[mapView.userLocation setSubtitle:@"vsp"];
return pinView;
}