全局设置:
if (@available(iOS 11.0, *)) {
/*typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior){
UIScrollViewContentInsetAdjustmentAutomatic, // 自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动的情况下也设置内边距
UIScrollViewContentInsetAdjustmentScrollableAxes, // 自动计算内边距
UIScrollViewContentInsetAdjustmentNever, // 不计算内边距
UIScrollViewContentInsetAdjustmentAlways, // 根据safeAreaInsets来计算内边距
} API_AVAILABLE(ios(11.0),tvos(11.0));*/
[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentAlways];
[[UITableView appearance] setEstimatedSectionFooterHeight:0.01];//默认段尾高度
[[UITableView appearance] setEstimatedSectionHeaderHeight:0.01];//默认段头高度
}
UITableView:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.01;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 8;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return [UIView new];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
return [UIView new];
}