我的地图中有 30 个注释,我想加快下降动画的速度。
是否可以加快 MKMapView 中注释的删除或一次删除所有注释?
我的地图中有 30 个注释,我想加快下降动画的速度。
是否可以加快 MKMapView 中注释的删除或一次删除所有注释?
您需要在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
.