iOS 13动画视图未更改框架

时间:2019-08-21 18:30:59

标签: ios objective-c uikit ios13

我有一个在iOS 13模拟器上以Xcode 10编译的应用程序。在一个视图中,有一个“托盘”视图,在点击时从底部显示,在iOS 12中它可以正常工作,在iOS 13中,水龙头调用了该方法,但是对框架的更改没有保存-我已包含输出从调试器中添加注释,以便您可以看到帧值的输出;

- (void) userClickActivityTray: (UITapGestureRecognizer *) gestureRecognizer {
if(self.activityTrayShown) {
    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     */
    [self hideActivityTray];
} else {
    if (!self.activityTrayViewInitialFrameComputed) {
        self.activityTrayViewInitialFrameComputed = YES;
        self.activityTrayInitialFrame = self.activityTrayContainerView.frame;
    }

    /*
     (lldb) po self.activityTrayContainerView.frame
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))
     (origin = (x = 0, y = 638), size = (width = 414, height = 224))

     (lldb) po self.activityTrayInitialFrame
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))
     (origin = (x = 0, y = 792), size = (width = 414, height = 104))

     (lldb)
     */

    [UIView animateWithDuration:0.25 animations:^{
        self.activityTrayContainerView.frame = CGRectMake(self.view.bounds.origin.x,
                                                          self.bottomView.frame.origin.y - self.activityTrayViewController.maximumHeight,
                                                          self.view.bounds.size.width,
                                                          self.activityTrayViewController.maximumHeight);

        self.activityTrayBackgroundView.alpha = 1.0;
        self.bottomView.alpha = self.dotsProgressView.alpha = 0;
    } completion:^(BOOL finished) {
        self.activityTrayShown = YES;
        /*
         (lldb) po self.activityTrayContainerView.frame
         (origin = (x = 0, y = 557), size = (width = 414, height = 305))
         (origin = (x = 0, y = 792), size = (width = 414, height = 104))
         */
    }];
}

}

4 个答案:

答案 0 :(得分:13)

iOS 13中的布局系统不同,我们遇到了相同的问题,在我们的案例中,将layoutautomatic切换为Translates Mask Into Constraints解决了该问题。

enter image description here

答案 1 :(得分:10)

您可以使用yourview.layer.frame代替yourview.frame 它对我有用。

答案 2 :(得分:3)

仅将.translatesAutoresizingMaskIntoConstraints的View设置为YES,它对我有用。 希望有帮助

答案 3 :(得分:2)

移至iOS13时,我遇到了同样的问题。 就我而言,调整大小的约束将覆盖我对框架所做的任何更改,而iOS12并非如此。 为了使我的应用程序正常运行,我还必须在“ animateWithDuration”块之前更新NSLayoutContraint,以使新的帧坐标与布局约束保持兼容。 希望有帮助