iOS11新增了安全区域的概念,其中组要是增加了下边这个类:
@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.
安全区域指的是视图不被一些bar和其他内容遮挡的部分。
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.
当视图在屏幕上显示的时候,guide反映了不被navigation bars,tabbar,toolbars和其他other ancestor views遮挡的部分。如果视图还没有添加在父视图上,或者好没有显示在屏幕上,ayout guide的边缘和视图的边缘平齐。
对于控制器的视图,layout guide集合了状态栏,其他可见bar,以及其他你应用了additionalSafeAreaInsets属性的控制器。
注意:safeArea最多向兼容到iOS9.0。如果兼容到8.0,那么将无法使用safeAreaLayoutGuide这个属性。