全局設置:
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];
}