是否在iPhone X的状态栏和多任务栏下方扩展视图,而无需手动调整代码约束? [英] Extend the View Underneath the Status Bar and Multi-tasking Bar on iPhone X Without Manually Adjusting Constraints in Code?

查看:85
本文介绍了是否在iPhone X的状态栏和多任务栏下方扩展视图,而无需手动调整代码约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以将视图扩展到iPhone X的状态栏和多任务栏下面,而无需手动根据设备调整代码中的约束.使用安全区域,容器,容器边距和顶部/底部布局指南似乎无济于事,因为状态栏在iPhone X上的高度与以前的iPhone不同,并且安全区域在多任务处理的顶部结束条,而它在以前的iPhone的屏幕底部结束.最重要的是,容器边距以及顶部和底部底部布局指南与安全区域相同,因此它们似乎也不起作用.似乎唯一的方法是使IBOutlet适应布局约束,并根据设备调整代码中的常量.有没有办法完全通过Interface Builder做到这一点?

I was wondering if there's a way to extend a view to be underneath the status bar and multi-tasking bar of the iPhone X without manually adjusting constraints in code based on the device. Using the safe area, container, container margins and top/bottom layout guides doesn't seem to help because the status bar is a different height on the iPhone X vs the previous iPhones and the safe area ends at the top of the multi-tasking bar whereas it ends at the bottom of the screen for previous iPhones. On top of that, the container margins, and top & bottom layout guides are the same as the safe area so those don't seem to work either. It seems like the only way is to make IBOutlets to the layout constraints and adjust the constants in code based on the device. Is there a way to do this purely through Interface Builder?

这是我要完成的示例

这是在非X iPhone上的外观.请注意,滚动视图如何在屏幕外从底部结束,而菠萝在顶部被切断.

推荐答案

我想出了解决此问题的方法.首先打开情节提要中的安全区域,然后:

I figured out how to fix the issue. First turn on safe area in your storyboard, then:

  1. 对于普通视图控制器,将视图限制为超级视图(顶部和/或底部).如果操作正确,则常数应为0,并且视图应与视图控制器的绝对顶部和/或底部齐平
  2. 对于表格视图,执行第1步,然后在表格视图仍处于选中状态的情况下,在大小检查器下,取消选中插入到安全区域",然后将内容插入"设置为从不"

这篇关于是否在iPhone X的状态栏和多任务栏下方扩展视图,而无需手动调整代码约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆