iOS 布局中的一些关键属性

2019-12-30  本文已影响0人  GTMYang

1. Bar(UINavigationBar, UITabBar, UIToolBar)相关

extendedLayoutIncludesOpaqueBars

var extendedLayoutIncludesOpaqueBars: Bool { get set } // 默认值为:NO

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 }

3. UIScrollView 相关

contentInset

var contentInset: UIEdgeInsets { get set }

设置 UIScrollView 的 padding 值的结构体(top, right, bottom, left)

adjustedContentInset

var adjustedContentInset: UIEdgeInsets { get }

automaticallyAdjustsScrollViewInsets

var automaticallyAdjustsScrollViewInsets: Bool { get set } // 默认值为:YES

如果 Controller 的 View 类型为 UIScrollView 或其子类,值为 YES 的时候会自动调整 contentInset 来保证内容不被导航栏和 TabBar 等 bar 遮挡。
值为 YES 的时候会自动计算 adjustedContentInset 的值

contentInsetAdjustmentBehavior

// 默认值:automatic
var contentInsetAdjustmentBehavior: UIScrollView.ContentInsetAdjustmentBehavior { get set } 
  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 }
上一篇下一篇

猜你喜欢

热点阅读