使用自动布局动画化 UIView

Animate Up UIView with Autolayout

当我尝试为 iPhoneX 的 UIView 设置动画时,自动布局出现了一些问题。正如您在第一张图片中看到的,我的 UIView 已关闭,所以我得到了我想要的...

结果

在第二张图片中,我尝试打开我的 UIView,但如您所见,space 保留在底部,而不是 iphone 7 加上没有 space ..

如何延长 uiview 的长度以覆盖底部缺失的 space?

我已经尝试从 Superview 中的安全区域更改我的第一个项目,但这给我带来了另一个问题,因为当我的 uiview 关闭时,它比 iphone 7 plus ...

结果


我需要的是这样的结果

你能帮帮我吗?

解决了 self.view.safeAreaInset.bottom...

当 UIView 关闭时,我以这种方式为约束 (loginPanelBottomConstraint) 设置动画:

[UIView animateWithDuration:.3 animations:^{
            self.loginPanelBottomConstraint.constant = 0 + self.view.safeAreaInsets.bottom;
            [self.view layoutIfNeeded];
        }];

打开面板时:

[UIView animateWithDuration:.3 animations:^{
                self.loginPanelBottomConstraint.constant = 245
                [self.view layoutIfNeeded];
            }];