我的地图中有30个注释,我想加快下降动画的速度。
是否有可能加快MKMapView中注释的删除或立即删除所有注释?
答案 0 :(得分:1)
您需要在didAddAnnotationViews
委托方法中实现自己的投放动画。您还应将animatesDrop
设置为NO
以避免可能的双重动画。
- (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;
}
}
这会以您指定的速率删除注释。
要一次删除所有内容,请将delay
参数硬编码为0.0
,而不是递增delayInterval
。