【问题标题】:Animate Up UIView with Autolayout使用 Autolayout 为 UIView 设置动画
【发布时间】:2018-09-17 15:10:18
【问题描述】:

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

结果

在第二张图片中,我尝试打开我的 UIView,但您可以看到底部的空间仍然存在,而不是在 iphone 7 plus 上没有剩余空间..

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

我已经尝试从 Superview 中的 Safe Area 更改我的第一个项目,但这给我带来了另一个问题,因为当我的 uiview 关闭时,它与 iphone 7 plus 相比下降太多......

结果


我需要的是得到这样的结果

你能帮帮我吗?

【问题讨论】:

    标签: objective-c xcode autolayout storyboard iphone-x


    【解决方案1】:

    已解决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];
                }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多