1. Bar(UINavigationBar, UITabBar, UIToolBar)相关
extendedLayoutIncludesOpaqueBars
var extendedLayoutIncludesOpaqueBars: Bool { get set } // 默认值为:NO
- self.navigationController .navigationBar.translucent = NO 时这个属性才起作用
- 值为YES的时候,Controller的View伸展到Bar的区域,bar层叠在View的上面(会遮挡住View)
edgesForExtendedLayout
var edgesForExtendedLayout: UIRectEdge { get set } // 默认值为:UIRectEdgeAll
设置Controller的View伸展到Bar的区域方式,有几个不同的方式:
UIRectEdgeNone = 0,
UIRectEdgeTop = 1 << 0,
UIRectEdgeLeft = 1 << 1,
UIRectEdgeBottom = 1 << 2,
UIRectEdgeRight = 1 << 3,
UIRectEdgeAll = UIRectEdgeTop | UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight
2. UIView 相关
safeAreaInset
var safeAreaInset: UIEdgeInsets { get }
- safeAreaInsets 是 readonly 属性
- 表示不安全部分的(top, right, bottom, left)值,典型的比如iPhoneX的刘海区域
3. UIScrollView 相关
contentInset
var contentInset: UIEdgeInsets { get set }
设置 UIScrollView 的 padding 值的结构体(top, right, bottom, left)
adjustedContentInset
var adjustedContentInset: UIEdgeInsets { get }
- 只读属性
- 根据 safeAreaInset 的值矫正之后的 contentInset 值
automaticallyAdjustsScrollViewInsets
var automaticallyAdjustsScrollViewInsets: Bool { get set } // 默认值为:YES
如果 Controller 的 View 类型为 UIScrollView 或其子类,值为 YES 的时候会自动调整 contentInset 来保证内容不被导航栏和 TabBar 等 bar 遮挡。
值为 YES 的时候会自动计算 adjustedContentInset 的值
contentInsetAdjustmentBehavior
// 默认值:automatic
var contentInsetAdjustmentBehavior: UIScrollView.ContentInsetAdjustmentBehavior { get set }
- 控制 adjustedContentInset 值的计算方式的枚举属性
- automaticallyAdjustsScrollViewInsets = YES 时才有效
- UIScrollView.ContentInsetAdjustmentBehavior 的几个值
case automatic // 竖直方向 adjustedContentInset = safeAreaInset + contentInset
case scrollableAxes // 科滚动方向 adjustedContentInset = safeAreaInset + contentInset
case never // adjustedContentInset = contentInset
case always // 任何方向 adjustedContentInset = safeAreaInset + contentInset
「contentInsetAdjustmentBehavior 详细说明」
UIViewController 相关
additionalSafeAreaInsets
var additionalSafeAreaInsets: UIEdgeInsets { get set }
- 通过设置该值可以调整 safeAreaInset 的值
网友评论