只需要在AppDelegate的didFinishLaunchingWithOptions方法中添加如下代码即可:
//适配iOS11
if (@available(ios 11.0,*)) {
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
UITableView.appearance.estimatedRowHeight = 0;
UITableView.appearance.estimatedSectionFooterHeight = 0;
UITableView.appearance.estimatedSectionHeaderHeight = 0;
}