动画删除注释 [英] Animate removal of annotations
问题描述
我有一张地图和一组注释,每个注释都有一个父属性。目前,当我添加注释时,我实现了didAddAnnotationViews方法来为这些注释设置动画,使它们看起来来自父级的坐标。在删除注释期间有没有办法做到这一点?当我从地图中删除注释时,我希望它在其父坐标中设置动画,据我所知,当删除注释时,didAddAnnotationViews没有等效项。
I have a map and a set of annotations, each with a 'parent' property. Currently when I add annotations I implement the didAddAnnotationViews method to animate those annotations so they appear to come from their parent's coordinate. Is there a way of doing this during the removal of annotations? When I remove an annotation from the map I want it to animate in to its parent coordinate, and as far as I know there is no equivalent for didAddAnnotationViews for when an annotation is removed.
推荐答案
动画注释之前将其从地图中移除并在动画完成后执行删除。代码可能如下所示:
Animate annotation before you remove it from the map and perform removal after animation is completed. The code may look like:
- (void) removeMyAnnotation:(MyAnnotation*)annotation{
[UIView animateWithDuration:1.0f
animations:^(void){
annotation.coordinate = annotation.parentAnnotation.coordinate;
}
completion:^(BOOL finished)completion{
[mapView removeAnnotation:annotation];
}
}
这篇关于动画删除注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!