0

As suggested by this popular answer, I am using blocks for animating views as per the code:

UIView *whiteout = [[UIView alloc] initWithFrame:self.view.frame];
whiteout.backgroundColor = [UIColor blackColor];
[self.view addSubview:whiteout];
[UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationTransitionFlipFromRight animations:^{ [whiteout removeFromSuperview]; } completion:nil];

However the animation does not happen and the whiteout view is removed immediately. What am i missing here??

Community
  • 1
  • 1
Shri
  • 2,129
  • 2
  • 22
  • 32

1 Answers1

3

Removing from a superview is not animatable. If you want to fade out your view, try setting its alpha to 0, then remove it on completion:

[UIView transitionWithView:self.view duration:2.0 options:UIViewAnimationTransitionFlipFromRight animations:^{
    whiteout.alpha = 0.0;
} completion:^(BOOL completion){
    [whiteout removeFromSuperview];
}];
CodaFi
  • 43,043
  • 8
  • 107
  • 153