YosiFZ
YosiFZ

Reputation: 7900

UIView transitionFromView change view heigh

I am using this code to change between 2 UIView:

UIViewAnimationOptions animationType = UIViewAnimationOptionTransitionFlipFromLeft;

[UIView transitionFromView:self.playlistTableView toView:self.playerView duration:0.5 options:animationType completion:^(BOOL finished){
     [self.containerView sendSubviewToBack:self.upperView];
     [self.containerView sendSubviewToBack:self.playerView];

     self.isPlaylistVisible = !self.isPlaylistVisible;
     isControlsHidden = NO;
}];

And i noticed a strange behavior, that when i made the flip the height of the self.playerView loosing 20px and after one second it's increase back to the normal frame size.

I try to change the animationType to UIViewAnimationOptionLayoutSubviews and now when i change between the view this behavior is not occur. Any idea what can be the issue?

Upvotes: 0

Views: 289

Answers (1)

Albin Joseph
Albin Joseph

Reputation: 1141

Please try this code.

        [self.upperView setHidden:YES];
        [self.playerView setHidden:NO];
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
        [UIView setAnimationDuration:1.0];
        [UIView commitAnimations];
        [containerView addSubview:self.playerView];

For getting reverse case

    [self.upperView setHidden:NO];
    [self.playerView setHidden:YES];
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:containerView cache:YES];
    [UIView setAnimationDuration:1.0];
    [UIView commitAnimations];
    [containerView addSubview:self.upperView];

Upvotes: 7

Related Questions