[5]|[5] Safe Area Layout (iOS 11)

UIView

  • 【[5]|[5] Safe Area Layout (iOS 11)】默认值:
    View Controller 的 View 的 safeAreaInsets (在viewDidAppear 查看):
    1. 不在Navigation Controller中:{20, 0, 0, 0 }
    2. 在Navigation Controller中:{64, 0, 0, 0 }
    3. View Controller 的 additionalSafeAreaInsets : {0, 0, 0, 0 }
  • 修改后:
    修改View Controller 的 additionalSafeAreaInsets 后:
    view.safeAreaInsets = view.safeAreaInsets + vc. additionalSafeAreaInsets
UIScrollView
由 contentInsetAdjustmentBehavior 决定:
  • never: adjustedContentInset = safeAreaInsets
  • always: adjustedContentInset = contentInset + safeAreaInsets
  • scrollableAxes:
    可滚动方向: adjustedContentInset = contentInset + safeAreaInsets
    可不滚动方向:adjustedContentInset = contentInset
  • automatic:
    automaticallyAdjustsScrollViewInsets = YES: adjustedContentInset = contentInset + safeAreaInsets
    automaticallyAdjustsScrollViewInsets = NO:与scrollableAxes 相同。
参考资料:
  • iOS 11 安全区域适配总结
  • Positioning Content Relative to the Safe Area

    推荐阅读