适配 ios11 和 iphonex

iOS11 适配

self sizing

1
2
3
4
5
if #available(iOS 11.0, *) {
UITableView.appearance().estimatedRowHeight = 0
UITableView.appearance().estimatedSectionHeaderHeight = 0
UITableView.appearance().estimatedSectionFooterHeight = 0
}

safeArea

https://www.jianshu.com/p/efbc8619d56b

  • topLayoutGuide
  • bottomLayoutGuide

  • contentInset
  • safeAreaInsets
  • addtionalSafeAreaInsets
  • adjustedContentInset
  • contentInsetAdjustmentBehavior

tableView 所有的 headers 和 footers 都应该使用 UITableViewHeaderFooterView

  1. titleView 和其他自定义视图需要用 autolayout

iPhoneX 适配

iPhoneX