Translucent: 是否半透明 (默认YES)
1. translucent为NO时:
edgesForExtendedLayout
属性指定边缘延伸的方向,默认为UIRectEdgeAll
,四周边缘均延伸。此时所有控制器的view不会延伸到navigationbar
(包含statebar)和 tabbar
的覆盖区域
2. translucent为YES时:
edgesForExtendedLayout
属性为默认(UIRectEdgeAll)时,所有控制器的view都会延伸到navigationbar(包含statebar)和tabbar覆盖的区域,如果不想延伸到覆盖区域可以设置edgesForExtendedLayout为UIRectEdgeNone
-
对于滚动视图
①
automaticallyAdjustsScrollViewInsets = YES
可自动调整内容至未被navigationbar
(包含statebar)和tabbar
覆盖的区域,即给navigationbar
(包含statebar)和tabbar
覆盖的区域预留出空白,默认为YES
。②
automaticallyAdjustsScrollViewInsets = NO
,滚动视图的内容仍会随着view
延伸到navigationbar
(包含statebar)和tabbar
覆盖的区域③ 若
edgesForExtendedLayout
属性置为UIRectEdgeNone
,控制器的view延伸到navigationbar
(包含statebar)和tabbar就不会延伸,且滚动视图也不会给navigationbar
(包含statebar)和tabbar覆盖的区域预留出空白 -
对于非滚动视图
①
automaticallyAdjustsScrollViewInsets
属性设置无效
② 若edgesForExtendedLayout
属性设置为UIRectEdgeNone
,控制器的view延伸到navigationbar
和tabbar
就不会延伸
当translucent
和edgesForExtendedLayout
为默认值时视图控制器的View
会延伸到navigationbar
和Tabbar
底下,如图1
当navigationbar
和Tabbar
的Translucent
都设置为NO
时,如图2
3. automaticallyAdjustsScrollViewInsets 和 contentInsetAdjustmentBehavior
1. automaticallyAdjustsScrollViewInsets
条件:iOS 9.0
、translucent
(YES)、edgesForExtendedLayout(UIRectEdgeNoneAll)
1. automaticallyAdjustsScrollViewInsets = YES (默认)
tableView 的大小为全屏大小 但是内容会从导航栏底下开始 并且在工具栏上面停止,即(自动调整内容大小不被导航栏和工具栏遮挡)
2. automaticallyAdjustsScrollViewInsets = NO
tableView 的大小为全屏大小,内容视图也为全屏大小 会被导航栏和工具栏遮住内容
2. contentInsetAdjustmentBehavior
在iOS11 中, UIViewController
的automaticallyAdjustsScrollViewInsets
属性已经不再使用,我们需要使用UIScrollView
的 contentInsetAdjustmentBehavior` 属性来替代它.
UIScrollViewContentInsetAdjustmentBehavior
是一个枚举类型,值有以下几种:
automatic
和scrollableAxes
一样,scrollView
会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.scrollableAxes
自动计算内边距. 在scrollView
不可滚动时,不会自动计算(会被导航栏和工具栏遮住)never
不计算内边距always
根据safeAreaInsets 计算内边距
条件tableView.scrollEnabled = NO
1. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
2. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentScrollableAxes
;