iOS11新增了安全區(qū)域的概念,其中組要是增加了下邊這個類:
@property(nonatomic,readonly,strong) UILayoutGuide *safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0));
簡介:
The layout guide representing the portion of your view that is unobscured by bars and other content.
安全區(qū)域指的是視圖不被一些bar和其他內(nèi)容遮擋的部分。
When the view is visible onscreen, this guide reflects the portion of the view that is not covered by navigation bars, tab bars, toolbars, and other ancestor views. (In tvOS, the safe area reflects the area not covered the screen's bezel.) If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the layout guide edges are equal to the edges of the view.
For the view controller's root view, the layout guide accommodates the status bar, other visible bars, and any additional insets that you specified using the?additionalSafeAreaInsets?property of your view controller. For other views in the view hierarchy, the layout guide reflects only the portion of the view that is covered by other content. For example, if a view is entirely within the safe area of its superview, the layout guide edges are equal to the edges of the view.
當(dāng)視圖在屏幕上顯示的時候,guide反映了不被navigation bars,tabbar,toolbars和其他other ancestor views遮擋的部分。如果視圖還沒有添加在父視圖上,或者好沒有顯示在屏幕上,ayout guide的邊緣和視圖的邊緣平齊。
對于控制器的視圖,layout guide集合了狀態(tài)欄,其他可見bar,以及其他你應(yīng)用了additionalSafeAreaInsets屬性的控制器。
注意:safeArea最多向兼容到iOS9.0。如果兼容到8.0,那么將無法使用safeAreaLayoutGuide這個屬性。