After Animation, View position resets

后端 未结 6 495
悲哀的现实
悲哀的现实 2020-12-08 10:42

I am trying to make a view slide from top to bottom. This is not a big deal, I used CABasicAnimation for this. The problem is when I want to remove the view. I

6条回答
  •  有刺的猬
    2020-12-08 11:02

    Might want to set these properties. They cause the presentation to be preserved at the end of the animation.

    animation.fillMode = kCAFillModeForwards;
    animation.removedOnCompletion = NO;

    Then the "animationDidStop:" method can be used to remove the view at the end of the animation:

    -(void) animationDidStop:(CAAnimation *) animation finished:(bool) flag {
        if (animation == [containerView.layer animationForKey:@"moveX"]) {
            // remove view here, add another view and/or start another transition
        }
    }
    

提交回复
热议问题