iPhoneX 適配

iPhoneX 適配

參考:

  1. developer.apple.com/videos/play…
  2. developer.apple.com/videos/play…
  3. medium.com/rosberryapp…
  4. medium.com/@kahseng.le…

參數:

lck_safeAreaLayoutGuide: Snap 中使用
lck_safeAreaInsets: Frame 佈局中使用, 在 layoutSubview 時生效
lck_keyWindowSafeAreaInsets: Frame 佈局中使用,全局生效ios

1. 適配 UITableView(UIScrollView/UICollection)

_tableView.snp.makeConstraints { (make) in
	make.leading.trailing.top.bottom.equalTo(0)
}
複製代碼

不須要作額外適配,在 contentInsetAdjustmentBehavior = .automatic 狀況下 contentOffSet 會自動適配 Home Indicatorapp

2. 適配自定義控件

// 定義 containerView
let containerView = UIView()
containerView.backgroundColor = _switchView.backgroundColor
addSubview(containerView)
containerView.snp.makeConstraints { (make) in
   make.leading.trailing.bottom.equalTo(0)
}
// 適配 safeArea
containerView.addSubview(_switchView)
    _switchView.snp.makeConstraints { (make) in
    make.leading.trailing.top.equalTo(0)   
    make.height.equalTo(44)
    make.bottom.equalTo(lck_safeAreaLayoutGuide)
}
複製代碼

3.未適配

self.navigationItem.searchController = searchController 由於導航欄底部分割線自定義存在問題iphone

4.其餘

left & leading: leading 佈局與 local 有關,一些國家閱讀習慣是從右往左, leading 會自動適配, 而 left 是絕對佈局ide

相關文章
相關標籤/搜索