UITableView:
UITableView里邊添加了一個屬性insetsContentViewsToSafeArea,默認值是YES,從字面意思很容易理解,他的內容是在安全區域中的。這樣做有什么好處嗎?這可以保證:我們可以看清楚表格里邊的內容,而不會被下邊的指示條遮擋。其實他就是增加了自己contentView的size實現的。
@property (nonatomic) BOOL insetsContentViewsToSafeArea API_AVAILABLE(ios(11.0), tvos(11.0)); // default value is YES
效果如下:
現在談論一下:
1.安全區域會對iOS8的用戶產生影響嗎?
首先如果你適配iOS8,那么安全區域你根本不可以使用,根本編譯不過去。
2.安全區域會對iOS11的iPhone6產生影響嗎?
iOS11之前寫的代碼,沒有安全區域(例如,XIB中都沒有安全區域這個東西),但是用戶升級iOS11之后,對于以前XIB寫的布局,由于沒有啟用安全區域布局,但是也不會受到影響,因為UITableView自帶了上邊這個屬性,不會導致遮擋。
UIScrollview
//When contentInsetAdjustmentBehavior allows, UIScrollView may incorporateits safeAreaInsets into the adjustedContentInset.
@property(nonatomic, readonly) UIEdgeInsets adjustedContentInset API_AVAILABLE(ios(11.0),tvos(11.0));
//Default is UIScrollViewContentInsetAdjustmentAutomatic.
@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior API_AVAILABLE(ios(11.0),tvos(11.0));
typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
//自動調整內邊距,當滾動視圖作為帶導航和tabbar的控制器的子視圖并且被豎直顯示的時候,總是會被調整;如果滾動視圖水平滾動,滾動內容的offset也會被調整到非0區域。
UIScrollViewContentInsetAdjustmentAutomatic,?
//在多方向滾動的時候,調整內邊距。頂部和底部的內邊距包含了安全區域的值
UIScrollViewContentInsetAdjustmentScrollableAxes,?
//內邊距從來不要調整,默認總是(0,0,0,0)
UIScrollViewContentInsetAdjustmentNever,?
//contentInset is always adjusted by the scroll view's safeAreaInsets。內邊距總是被調整到安全區域
UIScrollViewContentInsetAdjustmentAlways,?
} API_AVAILABLE(ios(11.0),tvos(11.0));