How to animate removeFromSuperview
Asked Answered
W

1

14

I animated the appearance of my subview with:

CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.type = kCATransitionReveal;
[webView.layer addAnimation:transition forKey:nil];

[self.view addSubview:webView];

But now I want to remove my subView. How can I add animation to do this? Like other CATransition? When to add this? Before or after addSubview?

Waldheim answered 22/5, 2012 at 11:15 Comment(0)
E
23

Well you could do the animation first and on the animationEndListener call removeFromSuperView

[UIView animateWithDuration:0.5
    delay:1.0
    options: UIViewAnimationOptionCurveEaseOut
    animations:^{
        yourView.alpha = 0;
    }completion:^(BOOL finished){
        [yourView removeFromSuperview];
    }];
Exudation answered 22/5, 2012 at 11:22 Comment(1)
not sure if this has changed, but the option now is: UIViewAnimationOptionCurveEaseOutZebedee

© 2022 - 2024 — McMap. All rights reserved.