本文介绍了以编程方式禁用UIView的安全区域布局指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
安全区域布局指南.该如何用代码完成?
Safe area layout guides can be disabled in Interface Builder by unchecking the Use Safe Area Layout Guides
. How can this be done in code?
我没有注意到与复选框直接对应的iOS11可用布尔值.
I didn't notice an iOS11-available boolean that directly corresponds with the checkbox.
推荐答案
我认为以编程方式完成此操作的唯一方法是覆盖safeAreaLayoutGuide属性.
I think the only way to accomplish this programmatically is to override the safeAreaLayoutGuide property.
override var safeAreaLayoutGuide: UILayoutGuide {
return UILayoutGuide()
}
当通过IB禁用它时,它仍然返回一个UILayoutGuide,但是layoutFrame为零,通过返回UILayoutGuide的一个实例,您基本上是在做同样的事情.
When you disable it through IB it still returns a UILayoutGuide but with zero layoutFrame, by returning an instance of UILayoutGuide, you are basically doing the same.
这篇关于以编程方式禁用UIView的安全区域布局指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!