简体   繁体   English

UIView transitionFromView更改视图高度

[英]UIView transitionFromView change view heigh

I am using this code to change between 2 UIView : 我正在使用此代码在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. 而且我注意到一个奇怪的行为,当我翻转self.playerView的高度时,其松动了20px,一秒钟后,它又变回了正常的帧大小。

I try to change the animationType to UIViewAnimationOptionLayoutSubviews and now when i change between the view this behavior is not occur. 我尝试将animationType更改为UIViewAnimationOptionLayoutSubviews ,现在当我在视图之间进行更改时,不会发生此行为。 Any idea what can be the issue? 知道是什么问题吗?

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM