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?

Fran Sevillano
  • 8,103
  • 4
  • 31
  • 45
Jakub
  • 13,712
  • 17
  • 82
  • 139

1 Answers1

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];
    }];
Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167